home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / appletalk / netatalk / afs / afsprivsrc.sit.hqx / AFS Privileges 1.50 / privileges.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-14  |  100.3 KB  |  3,611 lines

  1. /*
  2. ****************************************************************************
  3. *Copyright 1992 Regents of The University of Michigan - All Rights Reserved*
  4. *                                                                          *
  5. * Permission to use, copy, modify, and distribute this software and its    *
  6. * documentation for any purpose and without fee is hereby granted,         *
  7. * provided that the above copyright notice appears in all copies and that  *
  8. * both that copyright notice and this permission notice appear in          *
  9. * supporting documentation, and that the name of The University of Michigan*
  10. * not be used in advertising or publicity pertaining to distribution of    *
  11. * the software without specific, written prior permission. This software   *
  12. * is supplied as is without expressed or implied warranties of any kind.   *
  13. *                                                                          *
  14. *            Center for Information Technology Integration                 *
  15. *                  Information Technology Division                         *
  16. *                     The University of Michigan                           *
  17. *                       519 W. William Street                              *
  18. *                     Ann Arbor, Michigan 48103                            *
  19. *                         +1 313-764-5440                                  *
  20. *                       FAX: +1 313-764-4434                               *
  21. *                        info@citi.umich.edu                               *
  22. *                                                                          *
  23. ****************************************************************************
  24. */
  25.  
  26. /* version modified 10-13-92 for bug fixes, enhancements suggested by Robert John C., etc. */
  27.  
  28. #include     <AppleTalk.h>
  29. #include    <Balloons.h>
  30. #include    <Types.h>
  31. #include    <Files.h>
  32. #include    <Devices.h>
  33. #include    <Quickdraw.h>
  34. #include    <OSUtils.h>
  35. #include    <CType.h>
  36. #include    <Dialogs.h>
  37. #include    <Desk.h>
  38. #include     <Icons.h>
  39. #include    <Errors.h>
  40. #include    <Resources.h>
  41. #include     <Lists.h>
  42. #include    <Memory.h>
  43. #include    <SysEqu.h>
  44. #include    <Packages.h>
  45. #include    <ToolUtils.h>
  46. #include    <StdIO.h>
  47. #include    <String.h>
  48. #include    <Fonts.h>
  49. #include    <GestaltEqu.h>
  50. #include    <Menus.h>
  51. #include     <Sound.h>
  52. #include    <Traps.h>
  53. #include     <Windows.h>
  54. #include    <Quickdraw.h>
  55. #include    "Protos.h"
  56. #include    "AShare.h"
  57. #include     "CursorCtl.h"
  58.  
  59. #include    "xvcb.h"
  60. #include    "privileges.h"
  61.  
  62. #define DEBUG     0 
  63. #define    kOn    1
  64. #define kOff    0
  65.  
  66. typedef    short        SICN[16];
  67. typedef    SICN        *SICNList;
  68. typedef    SICNList    *SICNHand;
  69.  
  70. void quickcheck( short howmany );
  71.  
  72. extern void showInfoDialog( void );
  73.  
  74. pascal void firstBox( WindowPtr, short );
  75. pascal void secondBox( WindowPtr, short );
  76. pascal void bonusBox( WindowPtr, short );
  77. pascal void growBox( WindowPtr, short );
  78. pascal void popupBox( WindowPtr, short );
  79. pascal void newpopupBox( WindowPtr, short );
  80. pascal     void posornegBox( WindowPtr, short );
  81. pascal     void negativeBox( WindowPtr, short );
  82. Boolean getdirAcl( short, long );
  83. StringHandle getMacName( void );
  84. short     CompareandInsert( char listentry[255], char, short );
  85. void     gotoToplevel( void );
  86. void     shouldireallyquit( void );
  87. void     genericErrorstuff( long, short, short );
  88. void     deleteNegAclBox( void );
  89. void     createNegAclBox( void );
  90. void     sneakyNegative( long );
  91. void     noAFSmounted( void );
  92. void     makedirList( Str255 path, long vRefNum );
  93. void     showRights( short whichOne );
  94. void     bzero( char *p, long len );
  95. void     buildACL( void );
  96. void     termiNate( void );
  97. void     makeList( void );
  98. void     eventLoop( void );
  99. void     dirSelect( short );
  100. void     aclSelect( short ); 
  101. void    negSelect( short );
  102. void     doMenu( long );
  103. void     doDialog( short );
  104. void    addGroup( void );
  105. void     deleteGroup( void );
  106. void    resetPerm( short, short, short );
  107. void     aboutPriv( void ) ;
  108. void     instagroovyAcls( short );
  109. void     setupPopup( void ); // for system 5, 6 or so.... NOT 7...
  110. OSErr    GetIndVolume( short, char *volName, short *volRefNum);
  111.  
  112. /* GLOBALS!! */
  113. AVCB            *vcb;
  114. EventRecord        er;
  115. ListHandle        dirList,     /* the drive/directory list */
  116.                 gourList,    /* the positive acl list */
  117.                 gnegAcls,     /* negative acls end up in here */
  118.                 gpathList;     /* pathList is used to piece together the path and popupmenu */
  119. MenuHandle        gApplemenu, gFilemenu, gOptions, gSetmenu, gPopupMenu;
  120. DialogPtr        dp, dr;
  121. Handle            gWatchCursor;
  122. HParamBlockRec    gWhereweare;
  123. Rect            gsizeDialrect;
  124. Str255            gAclName; /* the name that appears in the add group function */
  125. WStateData        gWindowsize;
  126. short            gItem, gTopLevel = 0, /* this is the position on the path we're focused on */
  127.                 gManyAcls = 0, gAChange = kOff,
  128.                 gInitialize = kOff, gLocation = 0;
  129.             
  130. struct{
  131.     short    State, /* 0 for positive only mode, 1 for pos/neg mode */
  132.             Focus, /* focus 0 for left box, 1 for right box */
  133.             Permit; /* are we permitted to change acls on this directory? */
  134. } gWindowstats;
  135.  
  136. #define popupMenuCDEFProc 1008
  137. #ifndef popupPrivateData
  138.     struct popupPrivateData{
  139.         MenuHandle    mHandle; // handle to menu
  140.         short        mID;     // menu ID
  141.         SignedByte    mPrivate[];
  142.     };
  143.     
  144.     typedef struct popupPrivateData popupPrivateData;
  145. #endif
  146.  
  147. main( ) 
  148. {
  149.     Boolean            helpmanager;
  150.     FontInfo        fontStuff;
  151.     MenuHandle        editmenu, helpmenu;
  152.     Handle            nothingspecial, ditlhandle, xdef;
  153.     OSErr            err;
  154.     StringPtr        nameofmac;
  155.     StringHandle    somethingtypestring;
  156.     Rect            rView = { 27, 9, 169, 9+163-15 }, /* for drive/volume list */
  157.                     sView = { 25, 182, 25+107+5, 182+163-15 }, 
  158.                     tView = RECT_POPUPMENU,
  159.                     uView = { 0, 0, 0, 0 },
  160.                     firstbox = { 27-1, 9-1, 167+6, 9+163+1 }, /* for drive/volume list */
  161.                     secondbox = { 25-1, 182-1, 25+107+6, 182+163+1 },
  162.                     dataBounds = { 0, 0, 0, 2 },
  163.                     box = { 0, 0, 0, 0},
  164.                     popupbox = RECT_POPUPMENU,
  165.                     dialogRect = kmainDialogboxsize,
  166.                     /* two column list here.. one column for name, one for */
  167.                     /* MAGIC top secret -- acl -- number */
  168.                     boxit;
  169.     Point            nothing = { 0 , 0 }, /* just that */
  170.                     something = { 0, 0 };
  171.     long            newpopupAvailable;
  172.     short            boxthebutton, fontNum;
  173.     Cell            cSize;
  174.     int                theRow, gestalterror, myBit;
  175.         
  176.     MaxApplZone();
  177.     InitGraf((Ptr) &qd.thePort);
  178.     InitFonts();
  179.     InitWindows();
  180.     InitMenus();
  181.     TEInit();
  182.     InitDialogs(NULL);
  183.     InitCursor();
  184.     
  185.     gTopLevel = 0; /* level 1 is for the desktop */
  186.  
  187.     gWindowsize.stdState.top = 40;
  188.     gWindowsize.stdState.left = 40;
  189.     gWindowsize.stdState.bottom = ( 40+170 );
  190.     gWindowsize.stdState.right = ( 40+425 );
  191.     gWindowsize.userState = gWindowsize.stdState ;
  192.     
  193.     gWindowstats.State = 0;
  194.     gWindowstats.Focus = 0;
  195.     gWindowstats.Permit = 0;
  196.     
  197.     if (( gApplemenu = GetMenu(MENU_APPLE)) == NULL ) {
  198.         /* bombs out */
  199.         termiNate ;
  200.     }
  201.  
  202.     if (( gFilemenu = GetMenu(MENU_FILE)) == NULL ) {
  203.         termiNate ;
  204.     }
  205.     
  206.     if (( gOptions = GetMenu(MENU_OPTION )) == NULL ) {
  207.         termiNate ;
  208.     }
  209.     
  210.     if (( gSetmenu = GetMenu( MENU_CONVIN )) == NULL ) {
  211.         termiNate ;
  212.     }
  213.         
  214.     if (( editmenu = GetMenu(MENU_EDIT)) == NULL ) {
  215.     termiNate ;
  216.     }
  217.     
  218.     gWatchCursor = GetResource( 'acur', ACUR_SPIN );
  219.     
  220.     InsertMenu ( gApplemenu, 0);
  221.     InsertMenu ( gFilemenu, 0);
  222.     InsertMenu ( editmenu, 0);
  223.     InsertMenu ( gSetmenu, -1 ); // this one is hierarchial... 
  224.     InsertMenu ( gOptions, 0 );
  225.     
  226.     gestalterror = Gestalt( gestaltHelpMgrAttr, &newpopupAvailable );
  227.     if ( gestalterror == noErr ) {
  228.         myBit = gestaltHelpMgrPresent;
  229.         helpmanager = BitTst( &newpopupAvailable, 31-myBit );
  230.     }
  231.     
  232.     if ( helpmanager == true ){
  233.         err = HMGetHelpMenuHandle( &helpmenu );
  234.         if( err == noErr ){
  235.             if( helpmenu != NIL ){
  236.                 AppendMenu( helpmenu, "\pAFS Privileges Help" );
  237.             }
  238.         }
  239.     }
  240.     
  241.     AddResMenu (gApplemenu ,'DRVR') ; /* adding DA's */
  242.     DrawMenuBar();
  243.     
  244.     ditlhandle = GetResource( 'DITL', DITL_PRIV );
  245.     if( ditlhandle == NULL ) genericErrorstuff( -66670, kOff, 108 );
  246.     
  247.     if (( dp = NewDialog( nil, &dialogRect, "\pAFS Privileges", true, 
  248.                             zoomDocProc, (WindowPtr)-1, true, 0, ditlhandle )) == NULL ){
  249.         genericErrorstuff( -66670, kOff, 109 );
  250.         ExitToShell();
  251.     }
  252.     
  253.     SetPort( dp );
  254.     
  255.     InitCursorCtl( (acurHandle) gWatchCursor ) ;
  256.     Show_Cursor( ARROW_CURSOR );
  257.     HideDItem( dp, ITEM_NEGBOX );
  258.     HideDItem( dp, ITEM_NEGTITLE );
  259.     Show_Cursor((Cursors) ACUR_SPIN); 
  260.     
  261.     if (( xdef = Get1Resource( 'MDEF', wideMenuProc )) == NULL ) {
  262.         genericErrorstuff( -66670, kOff, 110 );
  263.         return( -1 );
  264.     }
  265.     
  266.     if (( gPopupMenu = NewMenu( MENU_POPUP, "\pnothing")) == NULL ) termiNate( );
  267.     (*gPopupMenu)->menuProc = xdef;
  268.     AppendMenu( gPopupMenu, "\pDesktop" );
  269.     GetDItem( dp, ITEM_POPUPMENU, &boxthebutton, ¬hingspecial, &boxit );
  270.     SetDItem( dp, ITEM_POPUPMENU, boxthebutton, (Handle)popupBox, &boxit );
  271.     
  272.     SetItemCmd( gPopupMenu, 1, 0x1e );
  273.     SetItemIcon( gPopupMenu, 1, SICN_DESK-256 ); // give the desktop icon to the DESKTOP entry!
  274.     ShowWindow( dp );
  275.     SpinCursor( 8 ); 
  276.     ClipRect( &box );
  277.     
  278.     GetFNum((StringPtr)"\pChicago",&fontNum); /* set our font */
  279.     TextFont(fontNum);
  280.     TextFace(0);
  281.     TextSize(12);
  282.     GetFontInfo( &fontStuff );
  283.     something.v = nothing.v = fontStuff.ascent+fontStuff.descent+fontStuff.leading;
  284.     nothing.h = rView.right - rView.left;
  285.     something.h = sView.right - sView.left;
  286.  
  287.     if (( gourList = LNew( &sView, &dataBounds, something, 0, dp, true, false, false, true )) == NULL ) {
  288.         genericErrorstuff( -66670, kOff, 111 );
  289.     }
  290.     (*gourList)->selFlags = lOnlyOne | lNoNilHilite;
  291.     
  292.     if (( dirList = LNew( &rView, &dataBounds, nothing, 0, dp, true, false, false, true )) == NULL ) {
  293.         genericErrorstuff( -66670, kOff, 112 );
  294.     }
  295.     (*dirList)->selFlags = lOnlyOne | lNoNilHilite;
  296.     SpinCursor( 8 );
  297.     
  298.     if (( gnegAcls = LNew( &sView, &dataBounds, something, 0, dp, false, false, false, true )) == NULL ) {
  299.         genericErrorstuff( -66670, kOff, 113 );
  300.     }
  301.     (*gnegAcls)->selFlags = lOnlyOne | lNoNilHilite;
  302.  
  303.     if (( gpathList = LNew( &tView, &dataBounds, nothing, 0, dp, false, false, false, false )) == NULL ) {
  304.         genericErrorstuff( -66670, kOff, 114 );
  305.     }
  306.     
  307.     theRow = LAddRow(1, 2000, gpathList); /* theRow should always be zero */
  308.     cSize.h = 0;
  309.     cSize.v = theRow;
  310.     LSetCell("Desktop", 7, cSize, gpathList);
  311.     
  312.     GetDItem( dp, ITEM_FIRSTBOX, &boxthebutton, ¬hingspecial, &boxit ); 
  313.     SetDItem( dp, ITEM_FIRSTBOX, boxthebutton, (Handle)firstBox, &boxit );
  314.     GetDItem( dp, ITEM_SECONDBOX, &boxthebutton, ¬hingspecial, &boxit );
  315.     SetDItem( dp, ITEM_SECONDBOX, boxthebutton, (Handle)secondBox, &boxit );
  316.     GetDItem( dp, ITEM_GROWBOX, &boxthebutton, ¬hingspecial, &boxit );
  317.     SetDItem( dp, ITEM_GROWBOX, boxthebutton, (Handle)growBox, &boxit );
  318.     GetDItem( dp, ITEM_POSITIVE, &boxthebutton, ¬hingspecial, &boxit );
  319.     SetDItem( dp, ITEM_POSITIVE, boxthebutton, (Handle)posornegBox, &boxit );
  320.     SpinCursor( 8 );
  321.  
  322.     bzero( (char *)&gWhereweare, sizeof( HParamBlockRec ));
  323.     gWhereweare.fileParam.ioCompletion = 0;
  324.     gWhereweare.fileParam.ioVRefNum = 0;
  325.     gWhereweare.fileParam.ioFDirIndex = 0;
  326.     gWhereweare.fileParam.ioDirID = 0;
  327.     
  328.     nameofmac = gAclName;
  329.     somethingtypestring = getMacName(); /* get the name of this macintosh */
  330.  
  331.     strncpy( nameofmac, *somethingtypestring, (int)(**somethingtypestring)+1);
  332.  
  333.     ClipRect( &dp->portRect);
  334.     InvalRect( &dp->portRect );
  335.     SpinCursor( 8 );
  336.     
  337.     makeList( );
  338.     gInitialize = kOn;
  339.     gsizeDialrect = dp->portRect;
  340.     Show_Cursor( ARROW_CURSOR );
  341.     eventLoop () ;
  342. } /* end main */
  343.  
  344. void termiNate() 
  345. {
  346.     WindowPtr    aWindow;
  347.     Boolean        closed;
  348.     
  349.     closed = true;
  350.     do {
  351.         aWindow = FrontWindow();        /* get the current front window */
  352.         if (aWindow != nil)
  353.             CloseWindow(aWindow);        /* close this window */    
  354.     }
  355.     while (aWindow != nil);
  356.     if (closed)
  357.         ExitToShell();                /* exit if no cancellation */
  358.     ExitToShell();
  359. } /*termiNate*/
  360.  
  361. void setupPopup( void ){
  362.     if (( gPopupMenu = NewMenu( MENU_POPUP, "\pnothing")) == NULL ) {
  363.         termiNate ;
  364.     }
  365.     AppendMenu( gPopupMenu, "\pDesktop" );
  366. }
  367.  
  368. #pragma segment utils
  369.  
  370. void genericErrorstuff( long anerror, short kontinue, short whereisit ){
  371.  
  372.     Handle    number;
  373.     Rect    numberbox;
  374.     char    duh[32];
  375.     short    okbuttontype, itemHit;
  376.     
  377.     if (( dr = GetNewDialog( DLOG_ERROR, NULL, (WindowPtr)-1 )) == NULL ) {
  378.         genericErrorstuff( -66670, kOff, 120 );
  379.         ExitToShell();
  380.     }
  381.  
  382.     SetPort( dr );
  383.     ShowWindow( dr );
  384.     GetDItem( dr, 7, &okbuttontype, &number, &numberbox );
  385.  
  386.     NumToString( whereisit, &duh );
  387.     SetIText( number, &duh );
  388.     GetDItem( dr, 3, &okbuttontype, &number, &numberbox );
  389.  
  390.     NumToString( anerror, &duh );
  391.     SetIText( number, &duh );
  392.     
  393.     if ( kontinue == kOff ) {
  394.         GetDItem( dr, 2, &okbuttontype, &number, &numberbox );
  395.         HiliteControl((ControlHandle)number, 255 );
  396.     }
  397.     
  398.     GetDItem( dr, 1, &okbuttontype, &number, &numberbox );
  399.     
  400.     PenSize(3,3);
  401.     InsetRect(&numberbox,-4,-4);
  402.     FrameRoundRect(&numberbox,16,16);
  403.     SysBeep( 0 );    
  404.     ModalDialog( nil, &itemHit );
  405.     switch( itemHit ) {
  406.     case 1 : /* hit the Quit button */
  407.             DisposDialog( dr );
  408.             termiNate( );
  409.             break;
  410.     case 2 : /* hit the Continue button */
  411.             DisposDialog( dr );
  412.             return;
  413.             break;
  414.     }
  415. }
  416.  
  417. StringHandle getMacName( void )
  418. {
  419.     StringHandle    macName;
  420.     short            saveResFile;
  421.     
  422.     saveResFile = CurResFile();
  423.     UseResFile(0);
  424.     macName = (StringHandle)Get1Resource('STR ', rUserName);
  425.     if ((!macName) || (!(**macName)))
  426.         macName = (StringHandle)Get1Resource('STR ', rMacintoshName);
  427.         
  428.     UseResFile(saveResFile);
  429.     if ((!macName) || (!(**macName)))
  430.         macName = (StringHandle)GetResource('STR ', rDefaultName);
  431.     return(macName);
  432. }
  433.  
  434. void noAFSmounted( void )
  435. {
  436.     SysBeep( 0 );
  437.     CautionAlert( ALRT_NOAFS, nil );
  438.     termiNate( );
  439. }
  440.  
  441. void sneakyNegative( long bigSize ) {
  442.     char    whatisit[50];
  443.     
  444.     SysBeep( 0 );
  445.     NumToString( bigSize, whatisit+1 );
  446.     whatisit[0] = strlen( whatisit+1 );
  447.     // I guess we should add some code to put "whatisit" into the alrt... i.e.
  448.     // this alrt needs to become a modal dialog...
  449.     
  450.     CautionAlert( ALRT_BOGNEG, nil );
  451.     return;
  452. }
  453.  
  454.  
  455.  
  456. #pragma segment privileges
  457.  
  458. void parseStr(buffer)
  459. char    *buffer;
  460. {
  461.     int    numPos, numNeg, i;
  462.     long    offset;
  463.     char    first[50];
  464.     int    value;
  465.     Point    cSize;
  466.     int    j;
  467.     int    theRow;
  468.     char    k;
  469.     int    flagofDOOM = 0;
  470.     
  471.     sscanf(buffer, "%d\n%d", &numPos, &numNeg);
  472.     buffer = strchr(buffer, 10) + 1;
  473.     buffer = strchr(buffer, 10) + 1;
  474.     for (i = numPos; i >0; i--)
  475.     {
  476.         SpinCursor( 8 );
  477.         sscanf(buffer, "%s %d", first, &value);
  478.         theRow = LAddRow(1, 2000, gourList);
  479.         cSize.h = 0;
  480.         cSize.v = theRow;
  481.         offset = strlen(first);
  482.         LSetCell(&first, offset, cSize, gourList);
  483.         cSize.h = 1;
  484.         j = 1;
  485.         k = value;
  486.         LSetCell(&k, j, cSize, gourList);
  487.         buffer = strchr(buffer, 10) + 1;
  488.     }
  489.     cSize.h = 0;
  490.     cSize.v = 0;
  491.     LSetSelect( true, cSize, gourList );
  492.     if (( gWindowstats.State == 1 ) && ( numNeg <= 0 )) {
  493.         deleteNegAclBox( );
  494.     }
  495.     if ( numNeg > 0 ) {
  496.         for (i = numNeg; i > 0; i--) {
  497.             SpinCursor( 8 );
  498.             sscanf(buffer, "%s %d", first, &value);
  499.             theRow = LAddRow(1, 2000, gnegAcls);
  500.             cSize.h = 0;
  501.             cSize.v = theRow;
  502.             offset = strlen(first);
  503.             LSetCell(&first, offset, cSize, gnegAcls);
  504.             cSize.h = 1;
  505.             j = 1;
  506.             k = value;
  507.             LSetCell(&k, j, cSize, gnegAcls);
  508.             buffer = strchr(buffer, 10) + 1;
  509.         }
  510.         cSize.h = 0;
  511.         cSize.v = 0;
  512.         if ( gWindowstats.State == 0 ) {
  513.             createNegAclBox( );            
  514.         }
  515.     }
  516. }
  517.  
  518. void showRights( short whichOne )
  519. {
  520. int     count, i = 0;
  521. long    j;
  522. Handle    rights[8];
  523. Point    theCell;
  524. Rect    boxit;
  525. short    boxthebutton, k = 1;
  526. char    um;
  527.  
  528.     for ( count=0; count<7; count++) {
  529.         GetDItem( dp, RIGHTS+count, &boxthebutton, &rights[count], &boxit );
  530.     }
  531.     theCell.v = whichOne ; /* hmmmmmmmm */
  532.     k = 1;
  533.     theCell.h = 0;
  534.  
  535.     if ( gWindowstats.Focus == 2 ) {
  536.         if( LGetSelect( true, &theCell, gnegAcls ) == false ) goto zero;
  537.         theCell.h = 1;
  538.         LGetCell( &um, &k, theCell, gnegAcls );
  539.     } else if ( gWindowstats.Focus == 1 ){
  540.         if( LGetSelect( true, &theCell, gourList ) == false ) goto zero;
  541.         theCell.h = 1;
  542.         LGetCell( &um, &k, theCell, gourList );
  543.     } else {
  544.     
  545.         /* well here we have a focus on the drive/dir list, 
  546.          * so we must figure out which one of the 
  547.          * two lists has something selected and then show those rights..*/
  548.         if ( LGetSelect( true, &theCell, gourList ) == false ) {
  549.             if( LGetSelect( true, &theCell, gnegAcls ) == false ){
  550.                 goto zero;
  551.             }
  552.             theCell.h = 1;
  553.             LGetCell( &um, &k, theCell, gnegAcls );
  554.         } else {
  555.             theCell.h = 1;
  556.             LGetCell( &um, &k, theCell, gourList );
  557.         }
  558.     }
  559.     i = um;
  560.  
  561. zero:    for (j=0; j<7; j++)
  562.     {
  563.         if ( i & ( 1<<j )) 
  564.             SetCtlValue( (ControlHandle) rights[j], 1 );
  565.         else 
  566.             SetCtlValue( (ControlHandle) rights[j], 0 );
  567.     }
  568. }
  569.  
  570. void addGroup(  )
  571. {
  572. /* the options dialog box for create/deleting files */
  573.  
  574.     short        itemHit = 0, type, theRow;
  575.     long        offset;
  576.     int        j;
  577.     Point        cSize;
  578.     DialogPtr    da;
  579.     Handle        groupname, okbutton;
  580.     Rect        numberbox;
  581.     char        nameofinterest[255], k;
  582.     Cell        whatcell = { 0, 0 }, oldcell = { 0, 0 };
  583.     
  584.     if (( da = GetNewDialog( DLOG_ADD, NULL, (WindowPtr)-1 )) == NULL ) {
  585.         genericErrorstuff( 87, 0, 1 );
  586.         ExitToShell();
  587.     }
  588.  
  589.     SetPort( da );
  590.     ShowWindow( da );
  591.     
  592.     GetDItem( da, ITEM_ADDGROUPEDIT, &type, &groupname, &numberbox );
  593.     GetDItem( da, ITEM_OK, &type, &okbutton, &numberbox);
  594.     
  595.     SetIText( groupname, gAclName ); /* the chooser/owner name would be cool here */
  596.     SelIText( da, ITEM_ADDGROUPEDIT, 0, 32767 );
  597.  
  598.     if( LGetSelect( true, &whatcell, dirList ) == false ) {
  599.         genericErrorstuff( 90002, kOn, 2 );
  600.         whatcell.v = 0;
  601.         whatcell.h = 0;
  602.     }
  603.     
  604.     PenSize(3,3);
  605.     InsetRect(&numberbox,-4,-4);
  606.     FrameRoundRect(&numberbox,16,16);
  607.     
  608.     for (;;) {
  609.         ModalDialog( nil, &itemHit );
  610.         switch( itemHit ) {
  611.         case ITEM_OK : /* hit the OK button */
  612.                 GetIText( groupname, &nameofinterest );
  613.                 if ( gWindowstats.Focus == 2 ) {
  614.                     LDoDraw( false, gnegAcls );
  615.                     theRow = LAddRow(1, 2000, gnegAcls);
  616.                     cSize.h = 0;
  617.                     cSize.v = theRow;
  618.                     offset = strlen( &nameofinterest );
  619.                     LSetCell(&nameofinterest+1, nameofinterest[0], cSize, gnegAcls);
  620.                     cSize.h = 1;
  621.                     j = 1;
  622.                     k = 0; /* DEFAULT ACL VALUE */
  623.                     LSetCell( &k, j, cSize, gnegAcls );
  624.                     if ( LGetSelect( true, &oldcell, gourList ) == true ) LSetSelect( false, oldcell, gourList );
  625.                     oldcell.h = 0;
  626.                     oldcell.v = 0;
  627.                     if ( LGetSelect( true, &oldcell, gnegAcls ) == true ) LSetSelect( false, oldcell, gnegAcls );
  628.                     cSize.h = 0;
  629.                     LSetSelect( true, cSize, gnegAcls );
  630.                     DisposDialog( da );
  631.                     SetPort( dp );
  632.                     gAChange = whatcell.v+1; /* tell buildACL to change the acl.. */
  633.                     LDoDraw( true, gnegAcls );
  634.                     InvalRect( &(*gnegAcls)->rView );
  635.                     showRights( 0 );
  636.                     return;
  637.                 } else {
  638.                     LDoDraw( false, gourList );
  639.                     theRow = LAddRow(1, 2000, gourList);
  640.                     cSize.h = 0;
  641.                     cSize.v = theRow;
  642.                     offset = strlen( &nameofinterest );
  643.                     LSetCell(&nameofinterest+1, nameofinterest[0], cSize, gourList);
  644.                     cSize.h = 1;
  645.                     j = 1;
  646.                     k = 0; /* DEFAULT ACL VALUE */
  647.                     LSetCell( &k, j, cSize, gourList );
  648.                     if ( LGetSelect( true, &oldcell, gnegAcls ) == true ) LSetSelect( false, oldcell, gnegAcls );
  649.                     oldcell.h = 0;
  650.                     oldcell.v = 0;
  651.                     if ( LGetSelect( true, &oldcell, gourList ) == true ) LSetSelect( false, oldcell, gourList );
  652.                     cSize.h = 0;
  653.                     LSetSelect( true, cSize, gourList );
  654.                     DisposDialog( da );
  655.                     SetPort( dp );
  656.                     gAChange = whatcell.v+1; /* tell buildACL to change the acl.. */
  657.                     LDoDraw( true, gourList );
  658.                     InvalRect( &(*gourList)->rView );
  659.                     showRights( 0 );
  660.                     return;
  661.                 }
  662.                 break;
  663.         case ITEM_CANCEL : /* hit the Cancel button */
  664.                 DisposDialog( da );
  665.                 return;
  666.                 break;
  667.         }
  668.     }
  669. }
  670.  
  671. void afterdeleteSelectanother( short posorneg, Cell whatcell ){
  672.     
  673.     if( posorneg == 1 ){ // negative box is being worked on....
  674.         LDelRow( 1, whatcell.v, gnegAcls );
  675.         LSetSelect( true, whatcell, gnegAcls );
  676.         if( LGetSelect( true, &whatcell, gnegAcls ) == false ) {
  677.             whatcell.v--;
  678.             LSetSelect( true, whatcell, gnegAcls );
  679.         }
  680.         showRights( whatcell.v );
  681.         return;
  682.     } else {
  683.         LDelRow( 1, whatcell.v, gourList );
  684.         LSetSelect( true, whatcell, gourList );
  685.         if( LGetSelect( true, &whatcell, gourList ) == false ) {
  686.             whatcell.v--;
  687.             LSetSelect( true, whatcell, gourList );
  688.         }
  689.         showRights( whatcell.v );
  690.         return;
  691.     }
  692. }
  693.     
  694.     
  695.  
  696. void deleteGroup(  )
  697. {
  698. /* delete an acl... */
  699.  
  700.     short        itemHit = 0, type, offset, focus;
  701.     DialogPtr    da;
  702.     Handle        groupname, okbutton;
  703.     Rect        numberbox;
  704.     char        nameofinterest[255];
  705.     Cell        whatcell = { 0, 0 };
  706.  
  707.     if ( gWindowstats.Focus == 2 ) {
  708.         if ( LGetSelect( true, &whatcell, gnegAcls ) == false) return;
  709.         focus = 1;
  710.     } else if ( gWindowstats.Focus == 1 ) {
  711.         if ( LGetSelect( true, &whatcell, gourList ) == false ) return;
  712.         focus = 0;
  713.     } else { 
  714.         // well, our focus must be on the drive/dir list so now we should figure out 
  715.         // which acl they are talking about...
  716.         if ( LGetSelect( true, &whatcell, gourList ) == false ) {
  717.             if( LGetSelect( true, &whatcell, gnegAcls ) == false ) return;
  718.             focus = 1;
  719.         } else focus = 0;
  720.     }
  721.     
  722.     if (( da = GetNewDialog( DLOG_DEL, NULL, (WindowPtr)-1 )) == NULL ) {
  723.         genericErrorstuff( -66666, kOff, 3 ); /* we should never be in here... */
  724.     }
  725.  
  726.     SetPort( da );
  727.     ShowWindow( da );
  728.     
  729.     GetDItem( da, ITEM_ADDGROUPEDIT, &type, &groupname, &numberbox );
  730.     GetDItem( da, ITEM_OK, &type, &okbutton, &numberbox);
  731.     if ( focus == 1 ) {
  732.         if (whatcell.h < 0) whatcell.h = 0; /* and if I didn't click on anything, get from  0,0 */
  733.         if (whatcell.v < 0) whatcell.v = 0;
  734.         offset = 255;
  735.         LGetCell( &nameofinterest+1, &offset, whatcell, gnegAcls );
  736.         nameofinterest[0] = offset;
  737.         nameofinterest[offset+1] = 0;
  738.         SetIText( groupname, nameofinterest );
  739.     } else {
  740.         if (whatcell.h < 0) whatcell.h = 0; /* and if I didn't click on anything, get from  0,0 */
  741.         if (whatcell.v < 0) whatcell.v = 0;
  742.         offset = 255;
  743.         LGetCell( &nameofinterest+1, &offset, whatcell, gourList );
  744.         nameofinterest[0] = offset;
  745.         nameofinterest[offset+1] = 0;
  746.         SetIText( groupname, nameofinterest );
  747.     }
  748.     
  749.     PenSize(3,3);
  750.     InsetRect(&numberbox,-4,-4);
  751.     FrameRoundRect(&numberbox,16,16);
  752.     
  753.     for (;;) {
  754.         ModalDialog( nil, &itemHit );
  755.         switch( itemHit ) {
  756.         case ITEM_OK : /* hit the OK button */
  757.                 if ( focus == 1 ) afterdeleteSelectanother( 1, whatcell );
  758.                 else afterdeleteSelectanother( 0, whatcell );
  759.                 whatcell.h = 0;
  760.                 whatcell.v = 0;
  761.                 if( LGetSelect( true, &whatcell, dirList ) == false ){
  762.                     genericErrorstuff( 90000, kOn, 4 );
  763.                 }
  764.                 gAChange = whatcell.v+1; /* tell buildACL to change the acl.. */
  765.                 DisposDialog( da );
  766.                 SetPort( dp );
  767.                 return;
  768.                 break;
  769.         case ITEM_CANCEL : /* hit the Cancel button */
  770.                 DisposDialog( da );
  771.                 SetPort( dp );
  772.                 return;
  773.                 break;
  774.         }
  775.     }
  776. }
  777.  
  778. void    resetPerm( short item, short whatrow, short value )
  779. {
  780. /* this function takes the value and pushes it into the acl-row */
  781.     
  782.     Cell         cSize = { 0, 0 };
  783.     Rect        myRect;
  784.     unsigned int    j, bigSize, i;
  785.     char        objectName[256];
  786.     unsigned char    right, k;
  787.     short        objSize, permSize, type, focus;
  788.     Handle        generichandle;
  789.     
  790.     GetDItem( dp, item, &type, &generichandle, &myRect );
  791.     
  792.     if ( gWindowstats.Focus == 1 ) focus = 1;
  793.     if ( gWindowstats.Focus == 2 ) focus = 2;
  794.     if ( gWindowstats.Focus == 0 ) {
  795.         if ( LGetSelect( true, &cSize, gourList ) == false ) {
  796.             if ( LGetSelect( true, &cSize, gnegAcls ) == false ) return;
  797.             focus = 2;
  798.         } else focus = 1;
  799.     }
  800.     
  801.     if ( focus == 2 ) {
  802.  
  803.         if( LGetSelect( true, &cSize, gnegAcls ) == false ) return;
  804.         
  805.         objSize = 255;
  806.         cSize.h = 0;
  807.         LGetCell(&objectName, &objSize, cSize, gnegAcls);
  808.         if (objSize != 0)
  809.         {
  810.             /* Get the permission string. */
  811.             cSize.h = 1;
  812.             permSize = 1;
  813.             LGetCell(&right, &permSize, cSize, gnegAcls);
  814.             i = bigSize = right;
  815.             if (bigSize < 0) { /* negative??  */
  816.                 sneakyNegative ( bigSize );
  817.             }
  818.             if ( i & value ) {
  819.                 bigSize = bigSize - value;
  820.                 SetCtlValue((ControlHandle)generichandle, 0 );
  821.             } else {
  822.                 bigSize = bigSize + value;
  823.                 SetCtlValue((ControlHandle)generichandle, 1 );
  824.             }
  825.             j = 1;
  826.             k = bigSize; 
  827.             LSetCell(&k, j, cSize, gnegAcls );
  828.             gAChange = whatrow+1; 
  829.             return;
  830.         } else genericErrorstuff( -66680, kOn, 5 ); /* we should never be in here... */
  831.     } else {
  832.         
  833.         if( LGetSelect( true, &cSize, gourList ) == false ) return;
  834.         
  835.         objSize = 255;
  836.         cSize.h = 0;
  837.         LGetCell(&objectName, &objSize, cSize, gourList);
  838.         if (objSize != 0)
  839.         {
  840.             /* Get the permission string. */
  841.             cSize.h = 1;
  842.             permSize = 1;
  843.             LGetCell(&right, &permSize, cSize, gourList);
  844.             i = bigSize = right;
  845.             if (bigSize < 0) { /* negative??  */
  846.                 sneakyNegative ( bigSize );
  847.             }
  848.             if ( i & value ) {
  849.                 bigSize = bigSize - value;
  850.                 SetCtlValue((ControlHandle)generichandle, 0 );
  851.             } else {
  852.                 bigSize = bigSize + value;
  853.                 SetCtlValue((ControlHandle)generichandle, 1 );
  854.             }
  855.             j = 1;
  856.             k = bigSize; 
  857.             LSetCell(&k, j, cSize, gourList);
  858.             gAChange = whatrow+1; 
  859.             return;
  860.         } else genericErrorstuff( -66670, kOn, 6 ); /* we should never be in here... */
  861.     }
  862. }
  863.  
  864. void buildACL( )
  865. {
  866.     Point        theCell, where={0,0}, cSize;
  867.     CInfoPBRec    cInfoRec;
  868.     HParamBlockRec    paramBlock;
  869.     char        objectName[256], negobjectName[256], permStr[256],
  870.                 volumeName[255], listName[255],
  871.                 path[255], right;
  872.     Handle        data;
  873.     short        objSize, permSize, volumeid,
  874.                 dataLen = 255, pathLen = 255, honkyflag = 0;
  875.     int            posn;
  876.     Byte        count, negcount;
  877.     long        totSize, bigSize, negSize, MyCurDir;
  878.     Handle        cmd;    
  879.     XPPParamBlock    xpp;
  880.     Handle        rights[9];
  881.     Rect        boxit;
  882.     short        boxthebutton, k = 1;
  883.     char        buffer[10], *ptr, up;
  884.     long        *did, error;
  885.     short        *vid;
  886.     OSErr        err;
  887.     short        xppRNum;
  888.     Boolean        done;
  889.     
  890.     if ( LGetSelect( true, &where, dirList) == false) {
  891.         where.h=0;
  892.         where.v=0;
  893.         LSetSelect( true, where, dirList );
  894.     }
  895.     
  896.     if ( gAChange > 0 ) where.v = gAChange-1; 
  897.     
  898.     if (gTopLevel < 1) { 
  899.         /* if we're on the volume level */
  900.         LGetCell( volumeName+1, &dataLen, where, dirList );
  901.         LGetCell( listName+1, &pathLen, where, dirList );
  902.         volumeName[0] = dataLen+1;
  903.         volumeName[dataLen+1] = ':';
  904.         where.h = 1;
  905.         dataLen = 1;
  906.         LGetCell( &up, &dataLen, where, dirList );
  907.         paramBlock.fileParam.ioVRefNum = -up;
  908.         paramBlock.volumeParam.ioVolIndex = 0;
  909.     } else {
  910.         /* if were down inside a volume */
  911.         LGetCell( listName+1, &pathLen, where, dirList );
  912.         where.h = 1;
  913.         dataLen = 1;
  914.         LGetCell( &up, &dataLen, where, dirList );
  915.         paramBlock.fileParam.ioVRefNum = up;
  916.         paramBlock.volumeParam.ioVolIndex = -1;
  917.         where.h = 0;
  918.         where.v = 1; /* this retrieves the volume name from our path list */
  919.         dataLen = 255;
  920.         LGetCell( volumeName+1, &dataLen, where, gpathList );
  921.         volumeName[0] = dataLen+1;
  922.         volumeName[dataLen+1] = ':';
  923.     }
  924.  
  925.     paramBlock.fileParam.ioNamePtr = volumeName;
  926.     paramBlock.fileParam.ioCompletion = 0;
  927.  
  928.     if ( err = (PBHGetVInfo( ¶mBlock, false )) != noErr ) {
  929.         genericErrorstuff( err, kOff, 7 ); /* we should never be in here... */
  930.     }
  931.     if ( paramBlock.fileParam.ioResult != noErr ) genericErrorstuff( -66672, kOff, 8 ); /* we should never be in here... */
  932.  
  933.     volumeid = paramBlock.fileParam.ioVRefNum;
  934.     if ( gTopLevel > 0 ) {
  935.         path[0] = path[1] = 0;
  936.         /* now piece together the path from our list */
  937.         for ( count=1; count<=gTopLevel; count++ ) {
  938.             SpinCursor( 12 );
  939.             cSize.h = 0;
  940.             cSize.v = count;
  941.             dataLen = 255;
  942.             LGetCell( listName+1, &dataLen, cSize, gpathList );
  943.             listName[dataLen+1] = ':';
  944.             listName[dataLen+2] = 0;
  945.             listName[0] = dataLen+1;
  946.             strcat( path+1, listName+1 );
  947.         }
  948.         path[0] = strlen( path+1 );
  949.         if (gAChange > 0) { /* this means we have one more name to add on... */
  950.             SpinCursor( 12 );
  951.             cSize.h = 0;
  952.             cSize.v = gAChange - 1;
  953.             dataLen = 255;
  954.             LGetCell( listName+1, &dataLen, cSize, dirList );
  955.             listName[dataLen+1] = ':';
  956.             listName[dataLen+2] = 0;
  957.             listName[0] = dataLen+1;
  958.             strcat( path+1, listName+1 );
  959.             path[0] = strlen( path+1 );
  960.         } else {
  961.             cSize.h = 0;
  962.             cSize.v = 0;
  963.             if( LGetSelect( true, &cSize, dirList ) == false ){
  964.                 // we end up in here if there's nothing inside the parent directory
  965.                 LSetSelect( true, cSize, dirList );
  966.                 LDelRow( 0, 2000, gourList ); /* deletes everything in the acl list */
  967.                 LDelRow( 0, 2000, gnegAcls );
  968.             }
  969.             if( cSize.v >= 0 ) {
  970.                 SpinCursor( 12 );
  971.                 dataLen = 255;
  972.                 LGetCell( listName+1, &dataLen, cSize, dirList );
  973.                 listName[dataLen+1] = ':';
  974.                 listName[dataLen+2] = 0;
  975.                 listName[0] = dataLen+1;
  976.                 strcat( path+1, listName+1 );
  977.                 path[0] = strlen( path+1 );
  978.             }
  979.         }
  980.  
  981.         cInfoRec.dirInfo.ioNamePtr = path;
  982.         cInfoRec.dirInfo.ioFDirIndex = 0;
  983.         cInfoRec.dirInfo.ioVRefNum = volumeid;                
  984.         cInfoRec.hFileInfo.ioFVersNum = 0;
  985.         cInfoRec.dirInfo.ioCompletion = 0;
  986.         cInfoRec.hFileInfo.ioDirID = 0;
  987.         if ( error = (PBGetCatInfo( &cInfoRec, false ) != noErr )) {
  988.             if( error != 1 ) { /* this kludge gets us out of bad bad netatalk returns */
  989.                 genericErrorstuff( -66675, kOff, 9 ); /* we should never be in here... */            
  990.             }
  991.         }
  992.         if ( cInfoRec.dirInfo.ioResult != noErr ) {
  993.             if( error != 1 ) { /* this kludge gets us out of bad bad netatalk returns */
  994.                 genericErrorstuff( -66676, kOff, 10); /* we should never be in here... */
  995.             }
  996.         }
  997.     } else strcpy( path,volumeName );
  998.     if ( gTopLevel == 0 ) {
  999.         MyCurDir = 2L; /* root directory of a vol is 2 */
  1000.     } else MyCurDir = cInfoRec.hFileInfo.ioDirID;
  1001.     
  1002. /* here's my attempt to get the vcb */
  1003.     vcb = (AVCB*)0x0358;
  1004.     done = false;
  1005.     while ((vcb != 0L) && !done)
  1006.     {
  1007.         SpinCursor( 12 );
  1008.         if (vcb->vcbVRefNum == volumeid)
  1009.         {
  1010.             if (vcb->vcbFSID != 0)
  1011.                 done = true;
  1012.             else    
  1013.                 vcb = (AVCB*)vcb->qLink;
  1014.         }
  1015.         else
  1016.             vcb = (AVCB*)vcb->qLink;
  1017.     }
  1018.  
  1019.     cInfoRec.dirInfo.ioNamePtr = path;
  1020.     cInfoRec.dirInfo.ioVRefNum = volumeid;
  1021.     cInfoRec.dirInfo.ioFDirIndex = -1;
  1022.     cInfoRec.dirInfo.ioDrDirID = MyCurDir;
  1023.     
  1024.     PBGetCatInfo(&cInfoRec,false);
  1025.     /* end lousy attempt to get vcb */
  1026.     
  1027.     totSize = 1;
  1028.     data = NewHandle(totSize);
  1029.     HLock(data);
  1030.     totSize = 0; // mike wisely enhanced this....
  1031.     HUnlock(data);
  1032.     theCell.v = 0;
  1033.     count = 0;
  1034.     negcount = 0;
  1035.  
  1036.     bzero( buffer, 10L);
  1037.     bzero( (char *)&xpp, sizeof(XPPParamBlock));
  1038.     if ( OpenXPP( &xppRNum ) != noErr ) {
  1039.         DebugStr("\p hey dude");
  1040.     }
  1041.     do
  1042.     {
  1043.         SpinCursor( 12 );
  1044.         objSize = 255;
  1045.         theCell.h = 0;
  1046.         LGetCell(&objectName, &objSize, theCell, gourList);
  1047.         if (objSize != 0)
  1048.         {
  1049.             /* Get the permission string. */
  1050.             theCell.h = 1;
  1051.             permSize = 1;
  1052.             LGetCell(&right, &permSize, theCell, gourList);
  1053.             bigSize = right;
  1054.             if (bigSize < 0)
  1055.                 bigSize = -bigSize + 128;
  1056.             NumToString(bigSize, &permStr);
  1057.             permSize = permStr[0];
  1058.             count++;
  1059.             posn = totSize;
  1060.             totSize = totSize + objSize + permSize + 2;
  1061.             SetHandleSize(data, totSize);  /* a space and then the byte */
  1062.             HLock(data);
  1063.             if ( count > 1 ) {
  1064.                 *((*data)+posn) = '\r';
  1065.                 posn++;
  1066.             } else totSize--;
  1067.             SpinCursor( 12 );
  1068.             bigSize = objSize;
  1069.             BlockMove(objectName, (*data)+posn, bigSize);
  1070.             posn += objSize;
  1071.             *((*data)+posn) = ' ';
  1072.             posn++;
  1073.             bigSize = permSize;
  1074.             BlockMove(&(permStr[1]), (*data)+posn, bigSize);
  1075.             HUnlock(data);
  1076.         }
  1077.     } while ( LNextCell(false,true, &theCell, gourList ));
  1078.     
  1079.     theCell.v = 0;
  1080.     theCell.h = 0;
  1081.     
  1082.     if ( LNextCell( true, true, &theCell, gnegAcls )){
  1083.         do
  1084.         {
  1085.             SpinCursor( 12 );
  1086.             objSize = 255;
  1087.             theCell.h = 0;
  1088.             LGetCell(&objectName, &objSize, theCell, gnegAcls);
  1089.             if (objSize != 0)
  1090.             {
  1091.                 /* Get the permission string. */
  1092.                 theCell.h = 1;
  1093.                 permSize = 1;
  1094.                 LGetCell(&right, &permSize, theCell, gnegAcls);
  1095.                 bigSize = right;
  1096.     /* I MAY WANT TO CHANGE THE BELOW... */
  1097.      
  1098.                 if (bigSize < 0)
  1099.                     bigSize = -bigSize + 128;
  1100.                 NumToString(bigSize, &permStr);
  1101.                 permSize = permStr[0];
  1102.                 negcount++;
  1103.                 posn = totSize;
  1104.                 totSize = totSize + objSize + permSize + 2;
  1105.                 SetHandleSize(data, totSize);  /* a space and then the byte */
  1106.                 HLock(data);
  1107.                 *((*data)+posn) = '\r';
  1108.                 posn++;
  1109.                 bigSize = objSize;
  1110.                 BlockMove(objectName, (*data)+posn, bigSize);
  1111.                 posn += objSize;
  1112.                 *((*data)+posn) = ' ';
  1113.                 posn++;
  1114.                 bigSize = permSize;
  1115.                 BlockMove(&(permStr[1]), (*data)+posn, bigSize);
  1116.                 HUnlock(data);
  1117.             }
  1118.         } while ( LNextCell(false,true, &theCell, gnegAcls ));
  1119.     }
  1120.  
  1121.     /* Write the number of positive acls. */
  1122.     bigSize = count;
  1123.     NumToString(bigSize, &objectName);
  1124.     bigSize = objectName[0];
  1125.  
  1126.     negSize = negcount;
  1127.     NumToString(negSize, &negobjectName);
  1128.     negSize = negobjectName[0];
  1129.  
  1130.     totSize += bigSize + 1 + negSize + 1 + 2;
  1131.     SetHandleSize(data, totSize);
  1132.     SpinCursor( 12 );
  1133.     HLock(data);
  1134.  
  1135.     BlockMove(*data , (*data) + bigSize + 1 + negSize + 1, totSize - bigSize - negSize - 2);
  1136.     *((*data)+0) = 'X';
  1137.     *((*data)+1) = 'X';
  1138.     *((*data)+2) = 'X';
  1139.     *((*data)+3) = 'X';
  1140.  
  1141.     BlockMove(&(objectName[1]), *data, bigSize);
  1142.     *((*data)+bigSize) = '\r';
  1143.     BlockMove(&(negobjectName[1]), ((*data)+bigSize+1), negSize );
  1144.     *((*data)+bigSize+1+negSize) = '\r';
  1145.     *((*data)+totSize - 2) = '\r';
  1146.     *((*data)+totSize - 1) = '\0';
  1147.  
  1148.     /* Build up the command request string */
  1149.     cmd = NewHandle(10L);
  1150.     HLock(cmd);
  1151.     ptr = *(char**)cmd;
  1152.     ptr[0] = 101;
  1153.     ptr[1] = 0;
  1154.     vid = (short*)&ptr[2];
  1155.     did = (long*)&ptr[4];
  1156.     
  1157.     *did = MyCurDir;   
  1158.     *vid = (short)vcb->vcbServerVol;
  1159.     ptr[8] = 2;
  1160.     ptr[9] = 0;
  1161.     HUnlock(cmd);
  1162.     HLock(data);
  1163.     HandAndHand(data, cmd);
  1164.     DisposHandle(data);
  1165.     HLock(cmd);
  1166.     
  1167.     // Gee, you don't even rate a cube huh?  // Dave
  1168.     /* Set up the AFP call, and send it off to WES */
  1169.     /* Look at setting timeouts better */
  1170.     xpp.XPP.sessRefnum = vcb->vcbSRefNum;
  1171.     xpp.XPP.ioRefNum = xppRNum;
  1172.     xpp.XPP.ioCompletion = 0L;
  1173.     xpp.XPP.csCode = 250;
  1174.     xpp.XPP.aspTimeout = 2;
  1175.     xpp.XPP.cbSize = GetHandleSize(cmd);
  1176.     xpp.XPP.cbPtr = *cmd;
  1177.     xpp.LOGIN.rbSize = 10;
  1178.     xpp.LOGIN.rbPtr = buffer;
  1179.     err = AFPCommand(&xpp, false);
  1180.     
  1181.     /* okay.. here lets highlight the controls accordingly... */
  1182.     
  1183.     for ( count=0; count<7; count++) {
  1184.         GetDItem( dp, RIGHTS+count, &boxthebutton, &rights[count], &boxit );
  1185.     }
  1186.     SpinCursor( 12 );
  1187.     GetDItem( dp, ADDBUTTON, &boxthebutton, &rights[7], &boxit );
  1188.     GetDItem( dp, REMBUTTON, &boxthebutton, &rights[8], &boxit );
  1189.  
  1190.     if (err) {
  1191.         if ( err != -1070 ) { /* THIS IS VERY RISKY..... */
  1192.             genericErrorstuff( err, kOff, 11 );
  1193.         }
  1194.     
  1195.     /* add this in later....    alert(AFPERROR) */
  1196.     }
  1197.     if (xpp.XPP.cmdResult != noErr ) {
  1198.         for( count=0; count<9; count++) {
  1199.             HiliteControl(( ControlHandle )rights[count], 255);
  1200.         }
  1201.         SetItem( gOptions, kSettings, "\pCan't Set Access Settings" );
  1202.         DisableItem( gOptions, kSettings );
  1203.         gWindowstats.Permit = 0; // no permission....
  1204.         DisposHandle(cmd);
  1205.         return;
  1206.     }
  1207.     for( count=0; count<9; count++) {
  1208.         HiliteControl(( ControlHandle )rights[count], 0);
  1209.         SetItem( gOptions, kSettings, "\pAccess Settings" );
  1210.         EnableItem( gOptions, kSettings );
  1211.         gWindowstats.Permit = 1; // you can permit things here....
  1212.     }
  1213.     DisposHandle(cmd);
  1214. }
  1215.  
  1216. void PlotSICN(Rect *theRect, SICNHand theSICN, long theIndex) {
  1217.        auto char   state;   /*saves original flags of 'SICN' handle*/
  1218.        auto BitMap srcBits; /*built up around 'SICN' data so we can _CopyBits*/
  1219.  
  1220.     if(( GetHandleSize((Handle)theSICN ) / sizeof(SICN )) > theIndex ) {
  1221.        /* store the resource's current locked/unlocked condition */
  1222.        state = HGetState((Handle)theSICN);
  1223.     
  1224.        /* lock the resource so it won't move during the _CopyBits call */
  1225.        HLock((Handle)theSICN);
  1226.     
  1227.        /* set up the small icon's bitmap */
  1228.        srcBits.baseAddr = (Ptr) (*theSICN)[theIndex];
  1229.        srcBits.rowBytes = 2;
  1230.        SetRect(&srcBits.bounds, 0, 0, 16, 16);
  1231.     
  1232.        /* draw the small icon in the current grafport */
  1233.        CopyBits(&srcBits,&(*qd.thePort).portBits,&srcBits.bounds, theRect,srcCopy,nil);
  1234.     
  1235.        /* restore the resource's locked/unlocked condition */
  1236.        HSetState((Handle) theSICN, state);
  1237.       }
  1238. }
  1239.  
  1240. void swapFocus( short wheretogo )
  1241. { /* simply swaps the focus between left and right.... */
  1242. Cell    celljack = { 0, 0 };
  1243. Rect    firstbox, secondbox, thirdbox;
  1244.  
  1245.     firstbox = (*dirList)->rView;
  1246.     secondbox = (*gourList)->rView;
  1247.     thirdbox = ( *gnegAcls )->rView;
  1248.     thirdbox.right = thirdbox.right+15;
  1249.     secondbox.right = secondbox.right+15;
  1250.     firstbox.right = firstbox.right+15;
  1251.     InsetRect( &thirdbox, -4, -4 );
  1252.     InsetRect( &firstbox, -4, -4);
  1253.     InsetRect( &secondbox, -4, -4); /* was 5 5 */
  1254.     
  1255.     PenSize(2,2);
  1256.     ForeColor( whiteColor );
  1257.     
  1258.     if ( gWindowstats.Focus == 2 ){
  1259.         if ( wheretogo == 1 ){
  1260.             // switching from negative acl box to positive acl box...
  1261.             // first thing we do is deselect whatever was in the negative acl box
  1262.             if ( LGetSelect( true, &celljack, gnegAcls ) == true ) LSetSelect( false, celljack, gnegAcls );
  1263.             FrameRect( &thirdbox );
  1264.             ForeColor( blackColor );
  1265.             FrameRect( &secondbox );
  1266.             
  1267.             // and then select the first thing that is in the positive list....
  1268.             celljack.h = 0;
  1269.             celljack.v = 0;
  1270.             if( LGetSelect( true, &celljack, gourList ) == false ) LSetSelect( true, celljack, gourList );
  1271.             showRights( celljack.v );
  1272.             gWindowstats.Focus = 1;
  1273.             PenSize( 1, 1 );
  1274.             return;
  1275.         } else {
  1276.             // well we must have clicked on the drive box, then...
  1277.             FrameRect( &thirdbox );
  1278.             ForeColor( blackColor );
  1279.             FrameRect( &firstbox );
  1280.             gWindowstats.Focus = 0;
  1281.             PenSize( 1, 1 );
  1282.             return;
  1283.         }
  1284.     }
  1285.     if ( gWindowstats.Focus == 1 ) {
  1286.         FrameRect( &secondbox );
  1287.         ForeColor( blackColor );
  1288.         if ( wheretogo == 2 ) {
  1289.             // switching from positive acl box to negative box....
  1290.             FrameRect( &thirdbox );
  1291.             gWindowstats.Focus = 2;
  1292.             if ( LGetSelect( true, &celljack, gourList ) == true ) LSetSelect( false, celljack, gourList );
  1293.             celljack.h = 0;
  1294.             celljack.v = 0;
  1295.             if( LGetSelect( true, &celljack, gnegAcls ) == false ) LSetSelect( true, celljack, gnegAcls );
  1296.             showRights( celljack.v );
  1297.         } else {
  1298.             // no negative acl state so just swap to drive box....
  1299.             FrameRect( &firstbox );
  1300.             gWindowstats.Focus = 0;
  1301.         }
  1302.         PenSize( 1, 1 );
  1303.         return;
  1304.     } else if ( gWindowstats.Focus == 0 ){
  1305.         FrameRect( &firstbox );
  1306.         ForeColor( blackColor );
  1307.         if (( wheretogo == 2 ) && ( gWindowstats.State == 1 )) {
  1308.             // going from drive list to negative acl box....
  1309.             // deselect whatever's in the positive acl box...
  1310.             FrameRect( &thirdbox );
  1311.             gWindowstats.Focus = 2;
  1312.             celljack.h = 0;
  1313.             celljack.v = 0;
  1314.             if( LGetSelect( true, &celljack, gourList ) == true ){
  1315.                 LSetSelect( false, celljack, gourList );    
  1316.             };
  1317.             celljack.h = 0;
  1318.             celljack.v = 0;
  1319.             if( LGetSelect( true, &celljack, gnegAcls ) == false ){
  1320.                 LSetSelect( true, celljack, gnegAcls );
  1321.             }
  1322.         } else {
  1323.             FrameRect( &secondbox );
  1324.             gWindowstats.Focus = 1;
  1325.             if ( gWindowstats.State == 1 ) {
  1326.                 // switching from drive list to positive acl box...
  1327.                 // deselect whatever's in the negative acl box
  1328.                 celljack.h = 0;
  1329.                 celljack.v = 0;
  1330.                 if( LGetSelect( true, &celljack, gnegAcls ) == true ){
  1331.                     LSetSelect( false, celljack, gnegAcls );    
  1332.                 };
  1333.                 celljack.h = 0;
  1334.                 celljack.v = 0;
  1335.                 if( LGetSelect( true, &celljack, gourList ) == false ){
  1336.                     LSetSelect( true, celljack, gourList );
  1337.                 }
  1338.             }
  1339.         }
  1340.         showRights( celljack.v );
  1341.     }
  1342.     PenSize(1,1);
  1343. }
  1344.  
  1345. void rswapFocus( void )
  1346. { /* simply swaps the focus between left and right.... */
  1347. Cell    celljack = { 0, 0 };
  1348. Rect    firstbox, secondbox, thirdbox;
  1349.  
  1350.     firstbox = (*dirList)->rView;
  1351.     secondbox = (*gourList)->rView;
  1352.     thirdbox = ( *gnegAcls )->rView;
  1353.     thirdbox.right = thirdbox.right+15;
  1354.     secondbox.right = secondbox.right+15;
  1355.     firstbox.right = firstbox.right+15;
  1356.     InsetRect( &thirdbox, -4, -4 );
  1357.     InsetRect( &firstbox, -4, -4);
  1358.     InsetRect( &secondbox, -4, -4); /* was 5 5 */
  1359.     
  1360.     PenSize( 2, 2 );
  1361.     ForeColor( whiteColor );
  1362.     if (( gWindowstats.Focus == 2 ) && ( gWindowstats.State == 1 )){
  1363.         // currently in negative ACL box, going to positive ACL box....
  1364.         FrameRect( &thirdbox );
  1365.         ForeColor( blackColor );
  1366.         FrameRect( &secondbox );
  1367.         if ( LGetSelect( true, &celljack, gnegAcls ) == true ) {
  1368.             LSetSelect( false, celljack, gnegAcls );
  1369.             LDraw( celljack, gnegAcls );
  1370.         }
  1371.         celljack.h = 0;
  1372.         celljack.v = 0;
  1373.         if( LGetSelect( true, &celljack, gourList ) == false ){
  1374.             LSetSelect( true, celljack, gourList );
  1375.         }
  1376.         gWindowstats.Focus = 1;
  1377.         showRights( celljack.v );
  1378.         PenSize( 1, 1 );
  1379.         return;
  1380.     } else if ( gWindowstats.Focus == 1 ) {
  1381.         // going from positive acl box to drive list....
  1382.         FrameRect( &secondbox );
  1383.         ForeColor( blackColor );
  1384.         FrameRect( &firstbox );
  1385.         gWindowstats.Focus = 0;
  1386.         PenSize( 1, 1 );
  1387.         return;        
  1388.     } else if ( gWindowstats.Focus == 0 ) {
  1389.         // go from drive box to negative acl box, if it exists...
  1390.         FrameRect( &firstbox );
  1391.         ForeColor( blackColor );
  1392.         if ( gWindowstats.State == 1 ) {
  1393.             FrameRect( &thirdbox );
  1394.             // switching from drive list to positive acl box...
  1395.             // deselect whatever's in the negative acl box
  1396.             if( LGetSelect( true, &celljack, gourList ) == true ){
  1397.                 LSetSelect( false, celljack, gourList );
  1398.                 LDraw( celljack, gourList );
  1399.             };
  1400.             celljack.h = 0;
  1401.             celljack.v = 0;
  1402.             if( LGetSelect( true, &celljack, gnegAcls ) == false ){
  1403.                 LSetSelect( true, celljack, gnegAcls );
  1404.             }
  1405.             gWindowstats.Focus = 2;
  1406.             showRights( celljack.v );
  1407.         } else {
  1408.             FrameRect( &secondbox );
  1409.             gWindowstats.Focus = 1;
  1410.         }
  1411.     }
  1412.     PenSize(1,1);
  1413. }
  1414.  
  1415. void downFocus( void )
  1416. {
  1417.     Cell    place = {0, 0}, oldplace;
  1418.     
  1419.     if ( gWindowstats.Focus == 2 ) { 
  1420.         // the action is happening in the negative acl List.... 
  1421.         if (LGetSelect( true, &place, gnegAcls ) == false) {
  1422.             showRights( 0 );
  1423.             return; /* there is nothing in the negative acl list so return */
  1424.         }
  1425.         oldplace = place;
  1426.         if ( LNextCell( false, true, &place, gnegAcls ) == true) {
  1427.             LSetSelect( false, oldplace, gnegAcls );
  1428.             LSetSelect( true, place, gnegAcls );
  1429.             LAutoScroll( gnegAcls );
  1430.         } 
  1431.         negSelect( 0 );
  1432.         return;
  1433.     }
  1434.  
  1435.     if ( gWindowstats.Focus == 0 ) { /* is the action happening in the drive list? */
  1436.         if (LGetSelect( true, &place, dirList ) == false) {
  1437.             genericErrorstuff( -66666, kOn, 12 ); /* we should never be in here... */
  1438.         }
  1439.         oldplace = place;
  1440.         if ( LNextCell( false, true, &place, dirList ) == true) {
  1441.             LSetSelect( false, oldplace, dirList );
  1442.             LSetSelect( true, place, dirList );
  1443.             LAutoScroll( dirList );
  1444.         }
  1445.         dirSelect( 0 );
  1446.         Show_Cursor( ARROW_CURSOR );
  1447.     } else {
  1448.         if (LGetSelect( true, &place, gourList ) == false) {
  1449.             showRights( 0 );
  1450.             return; /* there is nothing in the negative acl list so return */
  1451.         }
  1452.         oldplace = place;
  1453.         if ( LNextCell( false, true, &place, gourList ) == true) {
  1454.             LSetSelect( false, oldplace, gourList );
  1455.             LSetSelect( true, place, gourList );
  1456.             LAutoScroll( gourList );
  1457.         } 
  1458.         aclSelect( 0 );
  1459.     }
  1460. }
  1461.  
  1462. void upFocus( void )
  1463. {
  1464.     Cell    place = {0, 0}, oldplace;
  1465.     
  1466.     if ( gWindowstats.Focus == 2 ) {
  1467.         if (LGetSelect( true, &place, gnegAcls ) == false) {
  1468.             showRights( 0 );
  1469.             return; /* there is nothing in the negative acl list so return */
  1470.         }
  1471.         oldplace = place;
  1472.         place.v--;
  1473.         if ( place.v >= 0 ) {
  1474.             LSetSelect( false, oldplace, gnegAcls );
  1475.             LSetSelect( true, place, gnegAcls );
  1476.             LAutoScroll( gnegAcls );
  1477.         }
  1478.         negSelect( 0 );
  1479.     }
  1480.  
  1481.     if ( gWindowstats.Focus == 0 ) { /* is the action happening in the drive list? */
  1482.         if (LGetSelect( true, &place, dirList ) == false) {
  1483.             showRights( 0 );
  1484.             return; /* there is nothing in the negative acl list so return */
  1485.         }
  1486.         oldplace = place;
  1487.         place.v--;
  1488.         if ( place.v >= 0 ) {
  1489.             LSetSelect( false, oldplace, dirList );
  1490.             LSetSelect( true, place, dirList );
  1491.             LAutoScroll( dirList );
  1492.         }
  1493.         dirSelect( 0 );
  1494.         Show_Cursor( ARROW_CURSOR );
  1495.     } else {
  1496.         if (LGetSelect( true, &place, gourList ) == false) {
  1497.             showRights( 0 );
  1498.             return; /* there is nothing in the negative acl list so return */
  1499.         }
  1500.         oldplace = place;
  1501.         place.v--;
  1502.         if ( place.v >= 0 ) {
  1503.             LSetSelect( false, oldplace, gourList );
  1504.             LSetSelect( true, place, gourList );
  1505.             LAutoScroll( gourList );
  1506.         }
  1507.         aclSelect( 0 );
  1508.     }
  1509. }
  1510.  
  1511. void replotItall( void )
  1512. {
  1513.  
  1514.     Rect    myRect = { 0, 0, 0, 0 }, removebox, boxit, nutthinbox,
  1515.             addbox,
  1516.             oldRect, newRect, boogieRect;
  1517.     Handle    removehandle, addhandle, buttonHandle[7], nothingspecial;
  1518.     Point    inbetween, cellsz;
  1519.     float    heightchange, widthchange, olddialogheight, olddialogwidth,
  1520.             newdialogheight, newdialogwidth;
  1521.     short    addshort, removeshort, boxthebutton, btype;
  1522.     int        workonleft, workontop;
  1523.     
  1524.     LDoDraw( false, gourList );
  1525.     LDoDraw( false, dirList );
  1526.     
  1527.     SetPort( dp );
  1528.     newRect = dp->portRect;        /* the NEW rectangle... */
  1529.     EraseRect( &dp->portRect );    /* I don't want to see this shit goin' down.... */    
  1530.     ClipRect( &myRect );
  1531.     
  1532.     /* this code figures out the percentage change in our rectangle size */
  1533.     
  1534.     oldRect = gsizeDialrect;
  1535.     
  1536.     olddialogheight = ( oldRect.bottom - oldRect.top );
  1537.     olddialogwidth  = ( oldRect.right - oldRect.left );
  1538.     newdialogheight = ( newRect.bottom - newRect.top );
  1539.     newdialogwidth  = ( newRect.right - newRect.left );
  1540.  
  1541.     heightchange=( newdialogheight / olddialogheight );
  1542.     widthchange=( newdialogwidth / olddialogwidth );
  1543.  
  1544.     myRect = (*dirList)->rView;
  1545.     inbetween.h = myRect.right;
  1546.     inbetween.v = myRect.bottom;
  1547.     
  1548.     myRect.right = (myRect.right * widthchange);
  1549.     myRect.bottom = ( newRect.bottom - 6 );
  1550.     myRect.top = 27;
  1551.     myRect.left = 9;
  1552.     HideControl(( *dirList)->vScroll );
  1553.     cellsz.h = myRect.right-myRect.left+5;
  1554.     cellsz.v = (*dirList)->cellSize.v;
  1555.     LCellSize( cellsz, dirList );
  1556.     LSize(( myRect.right-myRect.left ), ( myRect.bottom - myRect.top ), dirList);
  1557.     (*dirList)->rView.right = myRect.right+1;
  1558.     (*dirList)->rView.top = myRect.top;
  1559.     (*dirList)->rView.bottom = myRect.bottom;
  1560.     (*dirList)->rView.left = myRect.left;
  1561.     
  1562.     MoveControl(( *dirList)->vScroll, myRect.right+2, myRect.top-1 );
  1563.     SizeControl(( *dirList)->vScroll, 15, ( myRect.bottom - myRect.top+2 ));
  1564.     myRect.right=myRect.right+15;
  1565.     GetDItem( dp, ITEM_FIRSTBOX, &boxthebutton, ¬hingspecial, &nutthinbox ); 
  1566.     SetDItem( dp, ITEM_FIRSTBOX, boxthebutton, (Handle)firstBox, &myRect );    
  1567.     
  1568.     myRect.left = ( myRect.right + 24 - 15 );
  1569.     myRect.right = ( newRect.right - 101 );
  1570.     myRect.bottom = ( newRect.bottom - 40 );
  1571.     myRect.top = 25;
  1572.     
  1573.     if ( gWindowstats.State == 1 ) myRect.bottom = ( myRect.bottom / 2 );
  1574.     
  1575.     boogieRect = (*gourList)->rView;
  1576.     inbetween.h = boogieRect.right;
  1577.     HideControl(( *gourList)->vScroll );
  1578.     cellsz.h = myRect.right-myRect.left+5;
  1579.     cellsz.v = (*gourList)->cellSize.v;
  1580.     LCellSize( cellsz, gourList );
  1581.     LSize(( myRect.right-myRect.left ), ( myRect.bottom - myRect.top ), gourList);
  1582.     
  1583.     (*gourList)->rView.right = myRect.right+1;
  1584.     (*gourList)->rView.top = myRect.top;
  1585.     (*gourList)->rView.bottom = myRect.bottom;
  1586.     (*gourList)->rView.left = myRect.left;
  1587.  
  1588.     MoveControl(( *gourList)->vScroll, myRect.right+2, myRect.top-1 );
  1589.     SizeControl(( *gourList)->vScroll, 15, ( myRect.bottom - myRect.top+2 ));
  1590.     myRect.right=myRect.right+15;
  1591.  
  1592.     GetDItem( dp, ITEM_SECONDBOX, &boxthebutton, ¬hingspecial, &nutthinbox );
  1593.     SetDItem( dp, ITEM_SECONDBOX, boxthebutton, (Handle)secondBox, &myRect );
  1594.     
  1595.     /* if the Negative ACL box is being displayed, then move the box around */
  1596.     if ( gWindowstats.State == 1 ) {
  1597.         myRect.top = myRect.bottom+30;
  1598.         myRect.right=myRect.right-15;
  1599.         myRect.bottom = ( dp->portRect.bottom-38 );
  1600.         
  1601.         boogieRect = (*gnegAcls)->rView;
  1602.         inbetween.h = boogieRect.right;
  1603.         HideControl(( *gnegAcls)->vScroll );
  1604.         cellsz.h = myRect.right-myRect.left;
  1605.         cellsz.v = (*gnegAcls)->cellSize.v;
  1606.         LCellSize( cellsz, gnegAcls );
  1607.         LSize(( myRect.right-myRect.left ), ( myRect.bottom - myRect.top ), gnegAcls);
  1608.         
  1609.         (*gnegAcls)->rView.right = myRect.right+1;
  1610.         (*gnegAcls)->rView.top = myRect.top;
  1611.         (*gnegAcls)->rView.bottom = myRect.bottom;
  1612.         (*gnegAcls)->rView.left = myRect.left;
  1613.  
  1614.         MoveControl(( *gnegAcls)->vScroll, myRect.right+2, myRect.top-1 );
  1615.         SizeControl(( *gnegAcls)->vScroll, 15, ( myRect.bottom - myRect.top+2 ));
  1616.         myRect.right=myRect.right+15;
  1617.         GetDItem( dp, ITEM_NEGBOX, &boxthebutton, ¬hingspecial, &nutthinbox );
  1618.         SetDItem( dp, ITEM_NEGBOX, boxthebutton, (Handle)bonusBox, &myRect );
  1619.     }
  1620.     
  1621.     // this bit of code moves the "positive" title
  1622.     GetDItem( dp, ITEM_POSITIVE, &boxthebutton, ¬hingspecial, &boxit );
  1623.     boxit.left = myRect.left;
  1624.     boxit.top = 2;
  1625.     boxit.bottom = 20;
  1626.     boxit.right = myRect.left + 110;
  1627.     SetDItem( dp, ITEM_POSITIVE, boxthebutton, (Handle)posornegBox, &boxit );
  1628.     
  1629.     inbetween.h = newRect.right;
  1630.     inbetween.v = newRect.bottom;
  1631.     
  1632.     GetDItem( dp, 10, &addshort, &addhandle, &addbox );
  1633.     workonleft = ( inbetween.h - 239 );
  1634.     workontop = ( inbetween.v - 30 ); 
  1635.  
  1636.     addbox.left = workonleft;
  1637.     addbox.top = workontop;
  1638.     addbox.right = workonleft+105;
  1639.     addbox.bottom = workontop+20;
  1640.  
  1641.     SetDItem( dp, 10, addshort, addhandle, &addbox );
  1642.     MoveControl((ControlHandle)addhandle, workonleft, workontop );
  1643.     
  1644.     GetDItem( dp, 11, &removeshort, &removehandle, &removebox );
  1645.     workonleft = ( inbetween.h - 125 );
  1646.     
  1647.     removebox.left = workonleft;
  1648.     removebox.top = workontop;
  1649.     removebox.right = workonleft+105;
  1650.     removebox.bottom = workontop+20;
  1651.  
  1652.     SetDItem( dp, 11, removeshort, removehandle, &removebox );
  1653.     MoveControl((ControlHandle)removehandle, workonleft, workontop );
  1654.  
  1655.     // move READ
  1656.     GetDItem( dp, 3, &btype, &buttonHandle[0], &removebox );
  1657.     workonleft = ( newRect.right - 79 );
  1658.     workontop = 9;
  1659.     removebox.left = workonleft;
  1660.     removebox.top = workontop;
  1661.     removebox.right = workonleft+106;
  1662.     removebox.bottom = workontop+18;
  1663.     SetDItem( dp, 3, btype, buttonHandle[0], &removebox );
  1664.     MoveControl((ControlHandle)buttonHandle[0], workonleft, workontop );
  1665.  
  1666.     // move WRITE    
  1667.     GetDItem( dp, 4, &btype, &buttonHandle[1], &removebox );
  1668.     workontop = 26;
  1669.     removebox.left = workonleft;
  1670.     removebox.top = workontop;
  1671.     removebox.right = workonleft+106;
  1672.     removebox.bottom = workontop+18;
  1673.     SetDItem( dp, 4, btype, buttonHandle[1], &removebox );
  1674.     MoveControl((ControlHandle)buttonHandle[1], workonleft, workontop );
  1675.  
  1676.     // move INSERT    
  1677.     GetDItem( dp, 5, &btype, &buttonHandle[2], &removebox );
  1678.     workontop = 43;
  1679.     MoveControl((ControlHandle)buttonHandle[2], workonleft, workontop );
  1680.     removebox.left = workonleft;
  1681.     removebox.top = workontop;
  1682.     removebox.right = workonleft+106;
  1683.     removebox.bottom = workontop+18;
  1684.     SetDItem( dp, 5, btype, buttonHandle[2], &removebox );
  1685.  
  1686.     // move LOOKUP    
  1687.     GetDItem( dp, 6, &btype, &buttonHandle[3], &removebox );
  1688.     workontop = 77;
  1689.     removebox.left = workonleft;
  1690.     removebox.top = workontop;
  1691.     removebox.right = workonleft+106;
  1692.     removebox.bottom = workontop+18;
  1693.     SetDItem( dp, 6, btype, buttonHandle[3], &removebox );
  1694.     MoveControl((ControlHandle)buttonHandle[3], workonleft, workontop );
  1695.  
  1696.     // move DELETE    
  1697.     GetDItem( dp, 7, &btype, &buttonHandle[4], &removebox );
  1698.     workontop = 60;
  1699.     removebox.left = workonleft;
  1700.     removebox.top = workontop;
  1701.     removebox.right = workonleft+106;
  1702.     removebox.bottom = workontop+18;
  1703.     SetDItem( dp, 7, btype, buttonHandle[4], &removebox );
  1704.     MoveControl((ControlHandle)buttonHandle[4], workonleft, workontop );
  1705.  
  1706.     // move LOCK    
  1707.     GetDItem( dp, 8, &btype, &buttonHandle[5], &removebox );
  1708.     workontop = 94;
  1709.     removebox.left = workonleft;
  1710.     removebox.top = workontop;
  1711.     removebox.right = workonleft+106;
  1712.     removebox.bottom = workontop+18;
  1713.     SetDItem( dp, 8, btype, buttonHandle[5], &removebox );
  1714.     MoveControl((ControlHandle)buttonHandle[5], workonleft, workontop );
  1715.  
  1716.     // move PERMIT    
  1717.     GetDItem( dp, 9, &btype, &buttonHandle[6], &removebox );
  1718.     workontop = 111;
  1719.     MoveControl((ControlHandle)buttonHandle[6], workonleft, workontop );
  1720.     removebox.left = workonleft;
  1721.     removebox.top = workontop;
  1722.     removebox.right = workonleft+106;
  1723.     removebox.bottom = workontop+18;
  1724.     SetDItem( dp, 9, btype, buttonHandle[6], &removebox );
  1725.  
  1726.     LDoDraw( true, gourList );
  1727.     LDoDraw( true, dirList );
  1728.     if ( gWindowstats.State == 1 ) {
  1729.         LDoDraw( true, gnegAcls );
  1730.     }
  1731.  
  1732.     ClipRect( &dp->portRect );
  1733.     InvalRect( &dp->portRect );
  1734.  
  1735.     gsizeDialrect = dp->portRect; /* set gsizeDialrect to our new-sized dialog box */
  1736.  
  1737. }
  1738.  
  1739. short    getAFSvol( short whichVol ){
  1740.  
  1741.     HParamBlockRec        audioCheck;
  1742.     OSErr                whaterror;
  1743.     char                volName[255];
  1744.     short                volRefNum;
  1745.     
  1746.     /* return positive number if we're out of volumes to count, as all  *
  1747.      * mounted volumes have negative vrefnumbers                          */
  1748.      
  1749.     if (GetIndVolume( whichVol, volName, &volRefNum) == nsvErr) return 1;
  1750.     
  1751.     vcb = (AVCB *)(getVCBbyrefnum( volRefNum ));
  1752.     SpinCursor( 8 );
  1753.     if (isafsVCB( vcb ) == true) {
  1754.         bzero(( char *)&audioCheck, sizeof( HParamBlockRec ));
  1755.         audioCheck.fileParam.ioCompletion = nil;
  1756.         audioCheck.fileParam.ioNamePtr = volName;
  1757.         audioCheck.fileParam.ioVRefNum = volRefNum;
  1758.         if( whaterror = PBHGetVInfo( &audioCheck, false ) != noErr ){
  1759.         genericErrorstuff((long)whaterror, kOn, 19 );
  1760.         }
  1761.         if (!( audioCheck.volumeParam.ioVFSID & 0x4A48 )){
  1762.             if (getdirAcl( volRefNum, OBNOXIOUSHIGHNUMBER ) == true) {
  1763.                 return volRefNum;
  1764.             }
  1765.         }
  1766.     }
  1767.     return 0;
  1768. }
  1769.  
  1770. void waiting( void ){
  1771.  
  1772.     DialogPtr             origPort, duhPort;
  1773.     Rect                popupRect = RECT_POPUPMENU;
  1774.     short                 returnednum, makelistflag, whichVol, oldvolcount, volcount, lo, duh;
  1775.     signed    short        mountedafsvols[256];
  1776.     
  1777.     LActivate( false, dirList );
  1778.     LActivate( false, gourList );
  1779.     LActivate( false, gnegAcls );
  1780.     
  1781.     volcount = 0;
  1782.     for( whichVol=1;;whichVol++ ){
  1783.         if(( returnednum = getAFSvol( whichVol )) > 0 ) break;
  1784.         else if( returnednum < 0 ){
  1785.             mountedafsvols[volcount++] = returnednum;
  1786.         }
  1787.     }
  1788.     
  1789.     mountedafsvols[volcount] = 0;
  1790.     
  1791.     for (;;) {
  1792.         if ( WaitNextEvent( updateMask+osMask, &er, 13, NIL )) {
  1793.             if ( er.what == osEvt ){
  1794.                 lo = (char) (( er.message & 0xff000000) >> 24);;
  1795.                 if( lo == suspendResumeMessage ){
  1796.                     if( er.message & resumeFlag ){
  1797.                         Show_Cursor((Cursors) ACUR_SPIN);
  1798.                     
  1799.                         /* go through our mounted AFS volume array that we created    *
  1800.                          * above and make sure that we have the same volumes on        *
  1801.                          * the desktop.  If not, turn a flag on and build the        *
  1802.                          * volume list again                                        */
  1803.                          
  1804.                         oldvolcount = volcount;
  1805.                         volcount = 0;                
  1806.                         makelistflag = 0;
  1807.                         for( whichVol=1;;whichVol++ ){
  1808.                             if(( returnednum = getAFSvol( whichVol )) > 0 ) break;                        
  1809.                             else if ( returnednum < 0 ){
  1810.                                 if( returnednum != mountedafsvols[volcount++] )
  1811.                                     makelistflag = 1;
  1812.                             }
  1813.                         }
  1814.                         
  1815.                         if( volcount != oldvolcount ) makelistflag = 1;
  1816.                         
  1817.                         LActivate( true, dirList );
  1818.                         LActivate( true, gourList );
  1819.                         LActivate( true, gnegAcls );                        
  1820.                         if( makelistflag == 1 ) {
  1821.                             gotoToplevel( );
  1822.                             EraseRect( &popupRect );
  1823.                             InvalRect( &popupRect );
  1824.                         }    
  1825.                         Show_Cursor( ARROW_CURSOR );
  1826.                         return;
  1827.                     }
  1828.                 }
  1829.             } else {
  1830.                 GetPort( &origPort );
  1831.                 SetPort( dp );
  1832.                 DialogSelect( &er, &duhPort, &duh );
  1833.                 SetPort( origPort );
  1834.             }
  1835.         }
  1836.     }
  1837. }
  1838.  
  1839. void eventLoop ()
  1840. {
  1841. DialogPtr    duhport;
  1842. Rect        sizeRect = { 170, 425, 3000, 3000 }, boundsRect = { 0, 0, 4096, 4096 }, myRect; 
  1843. Point        startPt;
  1844. WindowPtr    whichWindow;
  1845. long        whichMenuItem, returnedCharacter, newSize;
  1846. short        whereWindow, lo, hi, limit;
  1847.  
  1848.     for (;;) {
  1849.         if ( WaitNextEvent( everyEvent, &er, 1, NIL )) {
  1850.             /* this handles it when somebody mounts a volume or disk */
  1851.  
  1852.             if ( er.what == diskEvt ){
  1853.                 gotoToplevel( );
  1854.             }
  1855.         
  1856.             if ( er.what == osEvt ){
  1857.                 lo = (char) (( er.message & 0xff000000) >> 24);;
  1858.                 if( lo == suspendResumeMessage ){
  1859.                     if (!( er.message & resumeFlag )) waiting( );
  1860.                 }
  1861.             }
  1862.             
  1863.             if( gWindowstats.State == 0 ) limit = 1;
  1864.             else limit = 2;
  1865.             // first thing we look for, is key events..... 
  1866.             if ( er.what == keyDown ) { /* any key is being pressed */
  1867.                 if ( er.modifiers & cmdKey ) { /* it is a cmd key function */
  1868.                     whichMenuItem = MenuKey( er.message & charCodeMask );
  1869.                     doMenu( whichMenuItem );
  1870.                 } if ( er.modifiers & shiftKey ){ /* holding the SHIfT key down... */
  1871.                     returnedCharacter = ( BitAnd( er.message, keyCodeMask ));
  1872.                     lo = ( returnedCharacter & 0xffff) ;
  1873.                     if ( lo == kTABKEY ) rswapFocus( );
  1874.                 } else { /* More key events here XXX */
  1875.                     returnedCharacter = ( BitAnd( er.message, keyCodeMask ));
  1876.                     lo = ( returnedCharacter & 0xffff) ;
  1877.                     if ( lo == kTABKEY ){
  1878.                         if (gWindowstats.Focus+1 > limit) swapFocus( 0 );
  1879.                         else swapFocus( gWindowstats.Focus+1 );
  1880.                     }
  1881.                     else if ( lo == kDOWNKEY ) downFocus( );
  1882.                         else if ( lo == kUPKEY ) upFocus( );
  1883.                 }
  1884.             } else {    
  1885.                 /* insert dialog keyboard events here.... */
  1886.                 
  1887.                 if ( IsDialogEvent( &er )) {
  1888.                         if ( DialogSelect( &er, &duhport, &gItem )) {
  1889.                             doDialog( gItem );
  1890.                         }
  1891.                 } else {
  1892.                     /* is the mouse doing something in the menu? */
  1893.                     if ( er.what == mouseDown ) {
  1894.                         whereWindow = FindWindow( er.where, &whichWindow );
  1895.                         switch( whereWindow ) {
  1896.                         case inMenuBar :    /* in menu bar */
  1897.                             whichMenuItem = MenuSelect( er.where );
  1898.                             doMenu( whichMenuItem ) ;
  1899.                             break ;
  1900.                         
  1901.                         case inDrag :    /* in drag/title bar... */
  1902.                             startPt = er.where ;
  1903.                             DragWindow (whichWindow, startPt, &boundsRect) ;
  1904.                             break;
  1905.                             
  1906.                         case inGrow : /* in the grow box... */
  1907.                             if (whichWindow == dp ) {
  1908.                                 myRect = dp->portRect;
  1909.                                 startPt = er.where ;
  1910.                                 newSize = GrowWindow( dp, startPt, &sizeRect);
  1911.                                 if ( newSize != 0 ) { 
  1912.                                     hi = ((newSize) >> 16) ;
  1913.                                     lo = (newSize) ;
  1914.                                     InvalRect( &myRect );
  1915.                                     SizeWindow( dp, lo, hi, true );
  1916.                                     replotItall( );
  1917.                                 }
  1918.                                 break;
  1919.                             }
  1920.                             
  1921.                         case inZoomIn:  case inZoomOut:  /* in ZOOM box */
  1922.                             whereWindow = ( FindWindow (er.where, &dp ));
  1923.                             if (TrackBox( whichWindow, er.where, whereWindow )) {
  1924.                                 if ((whereWindow == inZoomOut) || (whereWindow == inZoomIn)) {
  1925.                                     SetPort( dp );
  1926.                                     myRect = dp->portRect;
  1927.                                     gWindowsize.userState = myRect;
  1928.                                     InvalRect( &myRect );
  1929.                                     EraseRect( &myRect );
  1930.                                     ZoomWindow( dp, whereWindow, true);
  1931.                                 }
  1932.                                 myRect = dp->portRect;
  1933.                                 ValidRect( &myRect );
  1934.                                 replotItall( );
  1935.                                 EndUpdate( dp );
  1936.                                 break;
  1937.                             }
  1938.                             break;
  1939.                             
  1940.                         case inGoAway :    /* in go-away box... */
  1941.                             if ( TrackGoAway( whichWindow, er.where ) == true) {
  1942.                                 if ( whichWindow == dp ) {
  1943.                                     shouldireallyquit( );
  1944.                                     CloseDialog ( dp ) ;
  1945.                                     termiNate ( ) ;
  1946.                                     break;
  1947.                                 }
  1948.                             } /* end shall I go away ? */
  1949.                             break;
  1950.                             
  1951.                         case inContent : /* in content region */
  1952.                             if (whichWindow == dp) {
  1953.                                 SelectWindow( dp );
  1954.                                 SetPort( dp );
  1955.                             }
  1956.                             break;
  1957.                         }
  1958.                     }
  1959.                 } 
  1960.             } 
  1961.         } 
  1962.     } 
  1963. }
  1964.  
  1965. short buildLoop ()
  1966. {
  1967. long        returnedCharacter;
  1968. short        lo;
  1969.  
  1970.     for (;;) {
  1971.         if ( WaitNextEvent( keyDownMask, &er, 1, NIL )) {
  1972.             // only thing we look for, is key events..... 
  1973.             if ( er.what == keyDown ) { /* any key is being pressed */
  1974.                 if ( er.modifiers & cmdKey ){ /* holding the COMMAND key down... */
  1975.                     returnedCharacter = ( BitAnd( er.message, keyCodeMask ));
  1976.                     lo = ( returnedCharacter & 0xffff) ;
  1977.                     if ( lo == kPeriod ) return 1;
  1978.                 } else { /* More key events here XXX */
  1979.                     returnedCharacter = ( BitAnd( er.message, keyCodeMask ));
  1980.                     lo = ( returnedCharacter & 0xffff) ;
  1981.                     if ( lo == kEscape ) return 1;
  1982.                 }
  1983.             }
  1984.         } 
  1985.         return 0;
  1986.     } 
  1987. }
  1988.  
  1989. void godownintoDirectory( void )
  1990. {
  1991.  
  1992.     Cell            cSize, where;
  1993.     OSErr            error;
  1994.     HParamBlockRec    paramBlock;
  1995.     Rect            badRect= RECT_POPUPMENU;
  1996.     char            listName[255], path[255], volumeName[255], down;
  1997.     long            directoryid = 0, volumeid;
  1998.     short            theRow, off, count, dataLen, pathLen, offset;
  1999.  
  2000.     /* user has clicked twice on a directory entry...
  2001.        so let's go INSIDE the directory  */
  2002.  
  2003.     Show_Cursor((Cursors) ACUR_SPIN);
  2004.     if ( gAChange > 0) { 
  2005.         buildACL( );
  2006.         gAChange = 0;
  2007.     }
  2008.     
  2009.     SpinCursor( 8 );
  2010.     LDelRow( 0, 2000, gourList ); /* deletes everything in the acl list */
  2011.     LDelRow( 0, 2000, gnegAcls );
  2012.     LDoDraw( false, gourList );
  2013.     LDoDraw( false, gnegAcls );
  2014.  
  2015.     /* initialize the path */
  2016.     for( count=0; count<256; count++ ) {
  2017.         path[count] = 0;
  2018.     }
  2019.     dataLen = 255;
  2020.     pathLen = 255;
  2021.     where.h = 0;
  2022.     where.v = 0;
  2023.     if ( !LGetSelect( true, &where, dirList )) {
  2024.         LSetSelect( true, where, dirList );
  2025.     }
  2026.     SpinCursor( 12 );
  2027.     gTopLevel++ ; /* we're going down.. so we ain't on the top level */
  2028.     bzero((char *)¶mBlock, sizeof( HParamBlockRec ));
  2029.     if (gTopLevel == 1) { /* if we're on the volume level */
  2030.         LGetCell( volumeName+1, &dataLen, where, dirList );
  2031.         LGetCell( listName+1, &pathLen, where, dirList );
  2032.     } else {
  2033.         LGetCell( listName+1, &pathLen, where, dirList );
  2034.         where.v = 1; /* this retrieves the volume name from our path list */
  2035.         LGetCell( volumeName+1, &dataLen, where, gpathList );
  2036.     }
  2037.  
  2038.     volumeName[0] = dataLen+1;
  2039.     volumeName[dataLen+1] = ':';
  2040.     dataLen = 1;
  2041.     where.h = 1;
  2042.     LGetCell( &down, &dataLen, where, dirList );
  2043.     paramBlock.fileParam.ioVRefNum = down;
  2044.     listName[0] = pathLen;
  2045.     paramBlock.fileParam.ioNamePtr = volumeName;
  2046.     paramBlock.fileParam.ioCompletion = 0;
  2047.     paramBlock.volumeParam.ioVolIndex = -1;
  2048.     SpinCursor( 12 );
  2049.  
  2050.     if ( error = PBHGetVInfo( ¶mBlock, false ) != noErr ) {
  2051.         genericErrorstuff((long)error, kOn, 13 );
  2052.     }
  2053.     if ( paramBlock.fileParam.ioResult != noErr ) genericErrorstuff((long) paramBlock.fileParam.ioResult, kOn, 14 );
  2054.     volumeid = paramBlock.fileParam.ioVRefNum;
  2055.  
  2056.     theRow = LAddRow( 1, 2000, gpathList); /* theRow should always be zero */
  2057.     cSize.h = 0;
  2058.     cSize.v = theRow;
  2059.     offset = pathLen;
  2060.     LSetCell(listName+1, offset, cSize, gpathList);
  2061.     
  2062.     InvalRect( &badRect );
  2063.     
  2064.     /* now piece together the path from our list */
  2065.  
  2066.     for ( count=1,off=1; count<=gTopLevel; count++ ) {
  2067.         SpinCursor( 12 );
  2068.         cSize.h = 0;
  2069.         cSize.v = count;
  2070.         dataLen = 255;
  2071.         LGetCell( listName+1, &dataLen, cSize, gpathList );
  2072.         listName[dataLen+1] = ':';
  2073.         listName[dataLen+2] = 0;
  2074.         listName[0] = dataLen+1;
  2075.         strcat( path+off, listName+1 );
  2076.         off += dataLen+1;
  2077.         path[0] = off;
  2078.     }
  2079.  
  2080.     path[0] = strlen( path+1 );
  2081.     
  2082.     listName[0]--; /* this thing gets rid of the colon */
  2083.     InsMenuItem( gPopupMenu, &listName, 0 );
  2084.     SetItemCmd( gPopupMenu, 1, 0x1e );
  2085.     if( gTopLevel == 1 ) SetItemIcon( gPopupMenu, 1, SICN_SHAR-256 );
  2086.     else SetItemIcon( gPopupMenu, 1, SICN_OPEN-256 );
  2087.  
  2088.     makedirList( path, paramBlock.fileParam.ioVRefNum );
  2089.  
  2090.     InvalRect( &badRect ); /* show the new name in the popup box */
  2091.     buildACL( );
  2092.     showRights( 0 );
  2093.     Show_Cursor( ARROW_CURSOR );
  2094.  
  2095. }
  2096.  
  2097. void dirSelect( short dooble )
  2098. {
  2099. Cell        cSize, where, quack = { 0, 0 }, originalSelect;
  2100. CInfoPBRec    cInfoRec;
  2101. HParamBlockRec    paramBlock;
  2102. OSErr        error;
  2103. Rect        badRect= RECT_POPUPMENU;
  2104. char        listName[255], path[255], volumeName[255], up;
  2105. long        directoryid = 0;
  2106. short        mitem=0, volumeid, count, dataLen, pathLen,
  2107.             swapFlag = kOff;
  2108.             
  2109.         /* doobie is the way we got in... if it's zero, if was done with a keydown */
  2110.         /* event... if it's a 1, then it was done by mousedown                     */
  2111.         if ( dooble == 0 ) goto zero; // <- this means we entered the routine via keydown...
  2112.         GlobalToLocal( &er.where );   // otherwise, the mouse did the dirty deed
  2113.         
  2114.         if (( gWindowstats.Focus == 1 ) || ( gWindowstats.Focus == 2 )) { 
  2115.             swapFocus( 0 );
  2116.             swapFlag = kOn;
  2117.         }
  2118.  
  2119.         if ( LClick( er.where, nil, dirList ) == true ) {
  2120.             godownintoDirectory( );
  2121.         } else {
  2122.  zero :            if ( gAChange > 0) { 
  2123.                 buildACL( );
  2124.                 gAChange = 0;
  2125.             }
  2126.             where.h = 0;
  2127.             where.v = 0;
  2128.             if ( !LGetSelect( true, &where, dirList )) {
  2129.                 where.v = (((*dirList)->dataBounds.bottom)-1);
  2130.                 LSetSelect( true, where, dirList );
  2131.             }
  2132.             originalSelect = where;
  2133.             /* we go in here when we click on drive list while focus was */
  2134.             /* still on the acl list .. if something valid was selected, */
  2135.             /* don't select 0 arbitrarily... */
  2136.             if ( swapFlag == kOn ) { 
  2137.                 quack = LLastClick( dirList );
  2138.                 /* if what we clicked on this time doesn't equal */
  2139.                 /* what was selected, check to see if it's greater */
  2140.                 /* than our bottom limit and if so... don't */
  2141.                 /* change the selection... */
  2142.                 if ( quack.v != where.v ) {
  2143.                     if ( quack.v <= (*dirList)->dataBounds.bottom ) {
  2144.                         LSetSelect( false, where, dirList );
  2145.                         LSetSelect( true, quack, dirList );
  2146.                         where.v = quack.v;
  2147.                     } 
  2148.                 }
  2149.             }  
  2150.             if ( where.v < 0 ) {
  2151.                 where.v = 0;
  2152.                 LSetSelect( true, where, dirList );
  2153.             }
  2154.             
  2155.             /* we go into here when we click on a new location in the drive list */
  2156.             if ( where.v != gLocation ) {
  2157.                 Show_Cursor( (Cursors) ACUR_SPIN);
  2158.                 LDelRow( 0, 2000, gourList ); /* deletes everything in the acl list */
  2159.                 LDelRow( 0, 2000, gnegAcls );
  2160.                 LDoDraw( false, gnegAcls );
  2161.                 LDoDraw( false, gourList );
  2162.                 bzero(( char *)¶mBlock, sizeof( HParamBlockRec ));
  2163.                 dataLen = 255;
  2164.                 SpinCursor( 12 );
  2165.                 if (gTopLevel < 1) { /* if we're on the volume level */
  2166.                     LGetCell( volumeName+1, &dataLen, where, dirList );
  2167.                     volumeName[0] = dataLen+1;
  2168.                     volumeName[dataLen+1] = ':';
  2169.                     where.h = 1;
  2170.                     dataLen = 1;
  2171.                     LGetCell( &up, &dataLen, where, dirList );
  2172.                     dataLen = 255;
  2173.                     LGetCell( listName+1, &pathLen, where, dirList );
  2174.                     paramBlock.fileParam.ioVRefNum=-up;
  2175.                     paramBlock.volumeParam.ioVolIndex = 0;
  2176.                 } else {
  2177.                     where.h = 1;
  2178.                     dataLen = 1;
  2179.                     LGetCell( &up, &dataLen, where, dirList );
  2180.                     dataLen = 255;
  2181.                     quack.h = 0;
  2182.                     quack.v = 1; /* this retrieves the volume name from our path list */
  2183.                     LGetCell( volumeName+1, &dataLen, quack, gpathList );
  2184.                     paramBlock.fileParam.ioVRefNum = up;
  2185.                     volumeName[0] = dataLen+1;
  2186.                     volumeName[dataLen+1] = ':';
  2187.                     paramBlock.volumeParam.ioVolIndex = -1;
  2188.                 }
  2189.                 paramBlock.fileParam.ioNamePtr = volumeName;
  2190.                 paramBlock.fileParam.ioCompletion = 0;
  2191.                 if ( error = PBHGetVInfo( ¶mBlock, false ) != noErr ) {
  2192.                     genericErrorstuff((long)error, kOn, 15 );
  2193.                 }
  2194.                 if ( paramBlock.fileParam.ioResult != noErr ) genericErrorstuff((long)paramBlock.fileParam.ioResult, kOn, 16 );
  2195.                 SpinCursor( 12 );
  2196.                 volumeid = paramBlock.fileParam.ioVRefNum;
  2197.                 path[1] = 0;
  2198.                 if (gTopLevel > 0) { /* only do this if we're not on the top level */
  2199.                     /* now piece together the path from our list */
  2200.                     for ( count=1; count<=gTopLevel; count++ ) {
  2201.                         SpinCursor( 12 );
  2202.                         cSize.h = 0;
  2203.                         cSize.v = count;
  2204.                         dataLen = 255;
  2205.                         LGetCell( listName+1, &dataLen, cSize, gpathList );
  2206.                         listName[0] = dataLen+1;
  2207.                         listName[dataLen+1] = ':';
  2208.                         listName[dataLen+2] = 0;
  2209.                         strcat( path+1, listName+1 );
  2210.                     }
  2211.                     dataLen = 255;
  2212.                     LGetCell( listName+1, &dataLen, originalSelect, dirList );
  2213.                     listName[dataLen+1] = ':';
  2214.                     listName[dataLen+2] = 0;
  2215.                     strcat( path+1, listName+1 );
  2216.                     path[0] = strlen( path+1 );
  2217.                     cInfoRec.dirInfo.ioNamePtr = path;
  2218.                     cInfoRec.dirInfo.ioFDirIndex = 0;
  2219.                     cInfoRec.dirInfo.ioVRefNum = volumeid;                
  2220.                     cInfoRec.hFileInfo.ioFVersNum = 0;
  2221.                     cInfoRec.dirInfo.ioCompletion = 0;
  2222.                     cInfoRec.hFileInfo.ioDirID = 0;
  2223.                     if ( error = (PBGetCatInfo( &cInfoRec, false ) != noErr )) {
  2224.                         genericErrorstuff((long) error, kOn, 17 );
  2225.                     }
  2226.                     if ( cInfoRec.dirInfo.ioResult != noErr ) genericErrorstuff((long)cInfoRec.dirInfo.ioResult, kOn, 18 );
  2227.                     directoryid = cInfoRec.hFileInfo.ioDirID;
  2228.                 }
  2229.                 SpinCursor( 12 );
  2230.                 getdirAcl( volumeid, directoryid );
  2231.                 if ( gTopLevel < 2 ) buildACL( ); /* we on the volume levels, check priv */
  2232.                 LDoDraw( true, gourList );
  2233.                 LUpdate( dp->visRgn, gourList );
  2234.                 if ( gWindowstats.State == 1 ) {
  2235.                     LDoDraw( true, gnegAcls );
  2236.                     LUpdate( dp->visRgn, gnegAcls );
  2237.                 }
  2238.                 showRights( 0 );
  2239.                 Show_Cursor( ARROW_CURSOR );
  2240.                 gLocation = where.v;
  2241.             }
  2242.     
  2243.         }
  2244. }
  2245.  
  2246. void aclSelect( short whichwayin )
  2247. {
  2248.     Cell where = { 0, 0 };
  2249.     
  2250.     GlobalToLocal( &er.where );
  2251.     if ( whichwayin == 0 ) goto zero;
  2252.     if ( LGetSelect( true, &where, gnegAcls )) LSetSelect( false, where, gnegAcls );
  2253.     if ( gWindowstats.Focus == 0 ) swapFocus( 0 );
  2254.     if ( gWindowstats.Focus == 2 ) swapFocus( 1 );
  2255.     if ( LClick( er.where, nil, gourList ) == true) {
  2256.         /* user has clicked twice on a different acl
  2257.            so let's update the buttons officially! */
  2258. //        SysBeep( 0 );  why confuse the twits?
  2259.     }
  2260. zero :    where.h = 0;
  2261.     where.v = 0;
  2262.     if ( LNextCell( true, true, &where, gourList ) == false ) {
  2263.         showRights( 0 );
  2264.         return;
  2265.     }
  2266.     where.h = 0;
  2267.     where.v = 0;
  2268.     if ( !LGetSelect( true, &where, gourList )) {
  2269.         where.v = (((*gourList)->dataBounds.bottom)-1);
  2270.         LSetSelect( true, where, gourList );
  2271.     }
  2272.     showRights( where.v ) ;
  2273. }
  2274.  
  2275. void negSelect( short whichwayin )
  2276. {
  2277.     Cell where = {0, 0};
  2278.  
  2279.     GlobalToLocal( &er.where );
  2280.     if ( whichwayin == 0 ) goto zero;
  2281.     
  2282.     if ( LGetSelect( true, &where, gourList )) LSetSelect( false, where, gourList);
  2283.     if ( gWindowstats.Focus == 1 ) swapFocus( 0 );
  2284.     if ( LClick( er.where, nil, gnegAcls ) == true) {
  2285.         SysBeep( 0 );
  2286.     }
  2287. zero :    where.h = 0;
  2288.     where.v = 0;
  2289.     if ( LNextCell( true, true, &where, gnegAcls ) == false ) {
  2290.         showRights( 0 );
  2291.         return;
  2292.     }
  2293.     where.h = 0;
  2294.     where.v = 0;
  2295.     if ( !LGetSelect( true, &where, gnegAcls )) {
  2296.         where.v = (((*gnegAcls)->dataBounds.bottom)-1);
  2297.         LSetSelect( true, where, gnegAcls );
  2298.     }
  2299.     showRights( where.v ) ;
  2300. }
  2301.  
  2302. void createNegAclBox( void ){
  2303.  
  2304. Cell        celljack = { 0, 0 };
  2305. FontInfo    fontStuff;
  2306. Handle        nothingspecial;
  2307. Point        inbetween, cellsz;
  2308. Rect        boogieRect, myRect={0, 0, 0, 0}, nobox;
  2309. short        boxthebutton;
  2310.  
  2311.     LDoDraw( false, gourList );
  2312.     LDoDraw( false, gnegAcls );
  2313.     
  2314.     gWindowstats.State = 1;
  2315.     boogieRect = dp->portRect;
  2316.     boogieRect.left = ((*gourList)->rView.left)-4;
  2317.     boogieRect.right = ((*gourList)->rView.right)+22;
  2318.     
  2319.     EraseRect( &boogieRect );
  2320.     ClipRect( &myRect );
  2321.     
  2322.     if ( gWindowstats.Focus == 1 ) { /* this code erases the focus box */
  2323.         myRect = (*gourList)->rView;
  2324.         myRect.right+=15;
  2325.         InsetRect( &myRect, -4, -4);
  2326.         PenSize( 2, 2 );
  2327.         ForeColor( whiteColor );
  2328.         FrameRect( &myRect );
  2329.         ForeColor( blackColor );
  2330.         PenSize( 1, 1 );
  2331.     }
  2332.  
  2333.     HideControl(( *gourList)->vScroll );
  2334.     HideControl(( *gnegAcls)->vScroll );
  2335.     
  2336.     myRect = (*gourList)->rView;
  2337.     boogieRect = myRect;
  2338.     InsetRect( &boogieRect, -4, -4 );
  2339.     EraseRect( &boogieRect );
  2340.  
  2341.     inbetween.h = myRect.right;
  2342.     inbetween.v = myRect.bottom;
  2343.     
  2344.     myRect.bottom = ( myRect.bottom / 2 );
  2345.  
  2346.     GetFontInfo( &fontStuff );
  2347.     
  2348.     boogieRect = (*gourList)->rView;
  2349.     inbetween.h = boogieRect.right;
  2350.     cellsz.h = myRect.right-myRect.left;
  2351.     cellsz.v = fontStuff.ascent+fontStuff.descent+fontStuff.leading;
  2352.     LCellSize( cellsz, gourList );
  2353.     LSize(( myRect.right-myRect.left ), ( myRect.bottom-myRect.top ), gourList);
  2354.     
  2355.     (*gourList)->rView.right = myRect.right;
  2356.     (*gourList)->rView.top = myRect.top;
  2357.     (*gourList)->rView.bottom = myRect.bottom;
  2358.     (*gourList)->rView.left = myRect.left;
  2359.  
  2360.     MoveControl(( *gourList)->vScroll, myRect.right+1, myRect.top-1 );
  2361.     SizeControl(( *gourList)->vScroll, 15, myRect.bottom-myRect.top+2 );
  2362.     myRect.right=myRect.right+15;
  2363.     GetDItem( dp, ITEM_SECONDBOX, &boxthebutton, ¬hingspecial, &nobox );
  2364.     SetDItem( dp, ITEM_SECONDBOX, boxthebutton, (Handle)secondBox, &myRect );
  2365.     myRect.right=myRect.right-15;
  2366.  
  2367.     GetDItem( dp, ITEM_NEGTITLE, &boxthebutton, ¬hingspecial, &nobox );
  2368.     nobox.top = myRect.bottom+5;
  2369.     nobox.bottom = myRect.bottom+23;
  2370.     nobox.left = myRect.left;
  2371.     nobox.right = myRect.left+132;
  2372.     SetDItem( dp, ITEM_NEGTITLE, boxthebutton, (Handle)negativeBox, &nobox );
  2373.     ShowDItem( dp, ITEM_NEGTITLE );
  2374.     
  2375.     myRect.top = myRect.bottom+30;
  2376.     myRect.bottom = ( dp->portRect.bottom-38 );    
  2377.     
  2378.     boogieRect = (*gnegAcls)->rView;
  2379.     inbetween.h = boogieRect.right;
  2380.     HideControl(( *gnegAcls)->vScroll );
  2381.     cellsz.h = myRect.right-myRect.left;
  2382.     cellsz.v = fontStuff.ascent+fontStuff.descent+fontStuff.leading;
  2383.     LCellSize( cellsz, gnegAcls );
  2384.     LSize( myRect.right-myRect.left, myRect.bottom-myRect.top, gnegAcls);
  2385.     
  2386.     (*gnegAcls)->rView.right = myRect.right;
  2387.     (*gnegAcls)->rView.top = myRect.top;
  2388.     (*gnegAcls)->rView.bottom = myRect.bottom;
  2389.     (*gnegAcls)->rView.left = myRect.left;
  2390.  
  2391.     MoveControl(( *gnegAcls)->vScroll, myRect.right+1, myRect.top-1 );
  2392.     SizeControl(( *gnegAcls)->vScroll, 15, myRect.bottom-myRect.top+2 );
  2393.     myRect.right=myRect.right+15;
  2394.     GetDItem( dp, ITEM_NEGBOX, &boxthebutton, ¬hingspecial, &nobox );
  2395.     SetDItem( dp, ITEM_NEGBOX, boxthebutton, (Handle)bonusBox, &myRect );
  2396.     ShowDItem( dp, ITEM_NEGBOX );
  2397.     
  2398.     LGetSelect( true, &celljack, gnegAcls );
  2399.     LSetSelect( false, celljack, gnegAcls );
  2400.  
  2401.     LDoDraw( true, gourList );
  2402.     LDoDraw( true, gnegAcls );
  2403.     
  2404.     ClipRect( &dp->portRect );
  2405.     InvalRect( &dp->portRect );
  2406.     SetItem( gOptions, 1, "\pHide Negative Access" );
  2407. }
  2408.  
  2409. short negdelDecision( void ) 
  2410. {
  2411.     short        itemHit = 0, okbuttontype, bitethisflag = 0;
  2412.     DialogPtr    dr;
  2413.     Rect        numberbox;
  2414.     Handle        number;
  2415.     
  2416.     if (( dr = GetNewDialog( DLOG_NEGDEL, NULL, (WindowPtr)-1 )) == NULL ) {
  2417.         genericErrorstuff( -66670, kOff, 130 );
  2418.         ExitToShell();
  2419.     }
  2420.     SetPort( dr );
  2421.     ShowWindow( dr );
  2422.  
  2423.     GetDItem( dr, ITEM_OK, &okbuttontype, &number, &numberbox );
  2424.     
  2425.     PenSize(3,3);
  2426.     InsetRect(&numberbox,-4,-4);
  2427.     FrameRoundRect(&numberbox,16,16);
  2428.     SysBeep( 0 );    
  2429.     ModalDialog( nil, &itemHit );
  2430.     switch( itemHit ) {
  2431.     case 1 : /* hit OK button */
  2432.             DisposDialog( dr );
  2433.             return 1;
  2434.             break;
  2435.     case 2 : /* hit CANCEL button */
  2436.             DisposDialog( dr );
  2437.             return 0;
  2438.             break;
  2439.     }
  2440. }
  2441.  
  2442. void deleteNegAclBox( void ){
  2443.  
  2444. Cell    celljack = { 0, 0 };
  2445. Handle    nothingspecial;
  2446. Point    inbetween, cellsz;
  2447. Rect    boogieRect, myRect = { 0, 0, 0, 0 }, nobox;
  2448. short    boxthebutton;
  2449.  
  2450.     if (( LNextCell( true, true, &celljack, gnegAcls ) == true ) && ( gWindowstats.Permit == kOn )) {
  2451.         if ( negdelDecision( ) == 0 ) return;
  2452.         SetPort( dp );
  2453.         LDoDraw( false, gnegAcls );
  2454.         LDelRow( 0, 2000, gnegAcls );
  2455.         LGetSelect( true, &celljack, dirList );
  2456.         gAChange = celljack.v+1;
  2457.         celljack.v = 0;
  2458.         celljack.h = 0;
  2459.     }
  2460.  
  2461.     // switch back to positive only state....
  2462.     gWindowstats.State = 0;
  2463.     LDoDraw( false, gourList );
  2464.     LDoDraw( false, gnegAcls );
  2465.  
  2466.     boogieRect = dp->portRect;
  2467.     boogieRect.left = ((*gourList)->rView.left)-4;
  2468.     boogieRect.right = ((*gourList)->rView.right)+4; 
  2469.     
  2470.     EraseRect( &boogieRect );
  2471.     ClipRect( &myRect );
  2472.     
  2473.     // insure that the crap in here is really history before you 
  2474.     // make it history.... which the LDelRow call below does....
  2475.     
  2476.     if ( gWindowstats.Focus == 1 ) { /* this code erases the focus box */
  2477.         myRect = (*gourList)->rView;
  2478.         myRect.right+=15;
  2479.         InsetRect( &myRect, -4, -4);
  2480.         PenSize( 2, 2 );
  2481.         ForeColor( whiteColor );
  2482.         FrameRect( &myRect );
  2483.         ForeColor( blackColor );
  2484.         PenSize( 1, 1 );
  2485.     }
  2486.     
  2487.     if ( gWindowstats.Focus == 2 ) { /* this code erases the focus box */
  2488.         myRect = (*gnegAcls)->rView;
  2489.         myRect.right+=15;
  2490.         InsetRect( &myRect, -4, -4);
  2491.         PenSize( 2, 2 );
  2492.         ForeColor( whiteColor );
  2493.         FrameRect( &myRect );
  2494.         ForeColor( blackColor );
  2495.         PenSize( 1, 1 );
  2496.         gWindowstats.Focus = 1;
  2497.     }
  2498.     
  2499.     myRect = (*gourList)->rView;
  2500.     myRect.bottom = dp->portRect.bottom;
  2501.  
  2502.     HideControl(( *gourList)->vScroll );
  2503.     HideControl(( *gnegAcls)->vScroll );
  2504.     HideDItem( dp, ITEM_NEGTITLE );
  2505.     HideDItem( dp, ITEM_NEGBOX );
  2506.     
  2507.     myRect = dp->portRect;
  2508.     
  2509.     myRect.top = 25;
  2510.     myRect.bottom = myRect.bottom - 40;
  2511.  
  2512.     boogieRect = (*gourList)->rView;
  2513.     myRect.left = boogieRect.left;
  2514.     myRect.right = boogieRect.right;
  2515.     
  2516.     inbetween.h = myRect.right;
  2517.     inbetween.v = myRect.bottom;
  2518.     
  2519.     cellsz.h = myRect.right-myRect.left;
  2520.     cellsz.v = (*gourList)->cellSize.v;
  2521.     LCellSize( cellsz, gourList );
  2522.     LSize(( myRect.right ), ( myRect.bottom ), gourList);
  2523.     
  2524.     (*gourList)->rView.right = myRect.right;
  2525.     (*gourList)->rView.top = myRect.top;
  2526.     (*gourList)->rView.bottom = myRect.bottom;
  2527.     (*gourList)->rView.left = myRect.left;
  2528.     
  2529.     MoveControl(( *gourList)->vScroll, myRect.right+1, myRect.top-1 );
  2530.     SizeControl(( *gourList)->vScroll, 15, myRect.bottom-myRect.top+2 );
  2531.     myRect.right=myRect.right+15;
  2532.     GetDItem( dp, ITEM_SECONDBOX, &boxthebutton, ¬hingspecial, &nobox );
  2533.     SetDItem( dp, ITEM_SECONDBOX, boxthebutton, (Handle)secondBox, &myRect );
  2534.     LDoDraw( true, gourList );
  2535.  
  2536.     ClipRect( &dp->portRect );
  2537.     InvalRect( &dp->portRect );
  2538.     SetItem( gOptions, 1, "\pShow Negative Access" );
  2539. }
  2540.  
  2541. void gotoToplevel( void ){
  2542.  
  2543.     int        theRow;
  2544.     short    count;
  2545.     Point    cSize;
  2546.     
  2547.     SetPort( dp );
  2548.     
  2549.     // user is going up to desktop level.... so delete everything except the "desktop" menu choice
  2550.     for ( count=(CountMItems( gPopupMenu )); count>1 ; count--)
  2551.         DelMenuItem( gPopupMenu, 1 );
  2552.     gTopLevel = 0;
  2553.     SpinCursor( 6 );
  2554.     LDelRow( 0, 2000, gourList ); /* deletes everything in the acl list */
  2555.     LDelRow( 0, 2000, dirList );
  2556.     LDelRow( 0, 2000, gnegAcls );
  2557.     LDelRow( 0, 2000, gpathList );
  2558.     gInitialize = kOff;
  2559.     gManyAcls = 0;
  2560.     makeList ( );
  2561.     gInitialize = kOn;
  2562.     theRow = LAddRow(1, 2000, gpathList); /* theRow should always be zero */
  2563.     cSize.h = 0;
  2564.     cSize.v = theRow;
  2565.     LSetCell("Desktop", 7, cSize, gpathList);
  2566.  
  2567. }
  2568.  
  2569. void popupPlay( void ){
  2570.  
  2571. Cell            where, cSize;
  2572. Point            topleft;
  2573. short            dataLen, count, mitem = 0, RealResult;
  2574. long            Result, directoryid = 0, volumeid, menuwidth;
  2575. int                PopUpItem = 0, theRow;
  2576. char            volumeName[255], path[255];
  2577. Str255            listName;
  2578. HParamBlockRec    paramBlock;
  2579. Rect            badRect = RECT_POPUPMENU;
  2580. short            number, anothernum;
  2581.  
  2582.     topleft = er.where;
  2583.     GlobalToLocal( &topleft );
  2584.     
  2585.     // don't bring down the popupmenu unless the user has clicked inside the popupmenu rect 
  2586.     if( topleft.h > ( badRect.left + (*gPopupMenu)->menuWidth )) return;
  2587.     
  2588.     /* now reset topleft for two konstants which tell the Mac where to place the popupmenu */
  2589.     topleft.v = badRect.top+1;
  2590.     topleft.h = badRect.left;
  2591.     LocalToGlobal( &topleft );
  2592.     
  2593.     InsertMenu( gPopupMenu, -1 );
  2594.     menuwidth = (*gPopupMenu)->menuWidth;
  2595.     Result = PopUpMenuSelect( gPopupMenu, topleft.v, topleft.h, PopUpItem );
  2596.  
  2597.     RealResult = (Result & 0xffff);
  2598.     (*gPopupMenu)->menuWidth  = menuwidth;
  2599.     
  2600.     // user wants to go UP???? 
  2601.     if ( RealResult > 1 ) { 
  2602.         Show_Cursor((Cursors) ACUR_SPIN );
  2603.         if ( gAChange > 0) { 
  2604.             buildACL( );
  2605.             gAChange = 0;
  2606.         }
  2607.         InvalRect( &badRect );
  2608.         if ((gTopLevel+1 - RealResult ) <= 0) {
  2609.             gotoToplevel( );
  2610.         } else {
  2611.             LDelRow( 0, 2000, gourList ); /* deletes everything in the acl list */
  2612.             LDelRow( 0, 2000, dirList );
  2613.             LDelRow( 0, 2000, gnegAcls );
  2614.             dataLen = 255;
  2615.             where.h = 0;
  2616.             where.v = 1; /* this retrieves the volume name from our path list */
  2617.             LGetCell( volumeName+1, &dataLen, where, gpathList );
  2618.             volumeName[0] = dataLen+1;
  2619.             volumeName[dataLen+1] = ':';
  2620.             SpinCursor( 6 );
  2621.             paramBlock.fileParam.ioNamePtr = volumeName;
  2622.             paramBlock.fileParam.ioVRefNum = 0;
  2623.             paramBlock.fileParam.ioCompletion = 0;
  2624.             paramBlock.volumeParam.ioVolIndex = -1;
  2625.             if ( PBHGetVInfo( ¶mBlock, false ) != noErr ) {
  2626.                 genericErrorstuff( -66670, kOn, 140 );
  2627.             }
  2628.             if ( paramBlock.fileParam.ioResult != noErr ) genericErrorstuff((long)paramBlock.fileParam.ioResult, kOn, 141 );
  2629.             volumeid = paramBlock.fileParam.ioVRefNum;
  2630.             theRow = (gTopLevel+1 - RealResult ); /* theRow should always be zero */
  2631.             cSize.h = 0;
  2632.             cSize.v = theRow;
  2633.             
  2634.             /* now piece together the path from our list */
  2635.             path[0] = path[1] = 0;
  2636.             gTopLevel = (CountMItems( gPopupMenu ) - RealResult );
  2637.             for ( count=1; count<=(CountMItems( gPopupMenu ) - RealResult ); count++ ) {
  2638.                 SpinCursor( 6 );
  2639.                 cSize.h = 0;
  2640.                 cSize.v = count;
  2641.                 dataLen = 255;
  2642.                 LGetCell( listName+1, &dataLen, cSize, gpathList );
  2643.                 listName[dataLen+1] = ':';
  2644.                 listName[dataLen+2] = 0;
  2645.                 listName[0] = dataLen+1;
  2646.                 strcat( path+1, listName+1 );
  2647.             }
  2648.             path[0] = strlen( path+1 );
  2649.             
  2650.             anothernum = (CountMItems( gPopupMenu ));
  2651.             number = (anothernum - ( anothernum - RealResult + 1 ));
  2652.             anothernum--;
  2653.             // delete pieces of the pop-up menu and pathlist that are gone...
  2654.             for ( count=0; count<number; count++){
  2655.                 DelMenuItem( gPopupMenu, 1 );
  2656.                 LDelRow( 1, anothernum--, gpathList );
  2657.             }
  2658.             makedirList( path, volumeid );
  2659.             buildACL( );
  2660.         } /* end else */
  2661.         gLocation = 0;
  2662.         InvalRect( &badRect );
  2663.         Show_Cursor( ARROW_CURSOR );
  2664.     }
  2665.     DeleteMenu( MENU_POPUP );
  2666. }
  2667.  
  2668. void doDialog( short    item )
  2669.  
  2670. {
  2671. Cell        where;
  2672. short        mitem = 0;
  2673. long        directoryid = 0;
  2674. Point        topleft;
  2675. int            PopUpItem = 0;
  2676. Rect        badRect = RECT_POPUPMENU;
  2677.     
  2678.     topleft.h = 9;
  2679.     topleft.v = 2;
  2680.     SetPort( dp );
  2681.     switch( item ) {
  2682.     case 1 : /* clicking on the drive/volume list */
  2683.         dirSelect( 1 );
  2684.         break;
  2685.  
  2686.     case 2 : /* clicking in the acl list */
  2687.         aclSelect( 1 );
  2688.         break;
  2689.         
  2690.     case ITEM_NEGBOX : // clicking in the negative ACL box...
  2691.         if ( gWindowstats.Focus != 2 ) swapFocus( 2 );
  2692.         if ( gWindowstats.State == 1 ) {   // just to be sure that the pos/neg state is enabled....
  2693.             negSelect( 1 );
  2694.         }
  2695.         break;
  2696.         
  2697.     case 10 : /* the add group button */
  2698.         addGroup(  );
  2699.         break;
  2700.         
  2701.     case 11 : /* the remove group button */
  2702.         deleteGroup( );
  2703.         break;
  2704.         
  2705.     case 12 : /* in the popup menu box */
  2706.     
  2707.         popupPlay( );
  2708.         break;
  2709.         
  2710.     case 3    : /* read */
  2711.         where.h = 0;
  2712.         where.v = 0;
  2713.         if ( !LGetSelect( true, &where, dirList )) {
  2714.             LSetSelect( true, where, dirList );
  2715.         }
  2716.         resetPerm( 3, where.v, 1 );
  2717.         break;
  2718.         
  2719.     case 4 : /* write */
  2720.         where.h = 0;
  2721.         where.v = 0;
  2722.         if ( !LGetSelect( true, &where, dirList )) {
  2723.             LSetSelect( true, where, dirList );
  2724.         }
  2725.         resetPerm( 4, where.v, 2 );
  2726.         break;
  2727.         
  2728.     case 5 : /* insert */
  2729.         where.h = 0;
  2730.         where.v = 0;
  2731.         if ( !LGetSelect( true, &where, dirList )) {
  2732.             LSetSelect( true, where, dirList );
  2733.         }
  2734.         resetPerm( 5, where.v, 4 );
  2735.         break;
  2736.         
  2737.     case 6 : /* lookup */
  2738.         where.h = 0;
  2739.         where.v = 0;
  2740.         if ( !LGetSelect( true, &where, dirList )) {
  2741.             LSetSelect( true, where, dirList );
  2742.         }
  2743.         resetPerm( 6, where.v, 8 );
  2744.         break;
  2745.         
  2746.     case 7 : /* lookup */
  2747.         where.h = 0;
  2748.         where.v = 0;
  2749.         if ( !LGetSelect( true, &where, dirList )) {
  2750.             LSetSelect( true, where, dirList );
  2751.         }
  2752.         resetPerm( 7, where.v, 16 );
  2753.         break;
  2754.         
  2755.     case 8 : /* lookup */
  2756.         where.h = 0;
  2757.         where.v = 0;
  2758.         if ( !LGetSelect( true, &where, dirList )) {
  2759.             LSetSelect( true, where, dirList );
  2760.         }
  2761.         resetPerm( 8, where.v, 32 );
  2762.         break;
  2763.         
  2764.     case 9 : /* administer */
  2765.         where.h = 0;
  2766.         where.v = 0;
  2767.         if ( !LGetSelect( true, &where, dirList )) {
  2768.             LSetSelect( true, where, dirList );
  2769.         }
  2770.         resetPerm( 9, where.v, 64 );
  2771.         break;
  2772.     }
  2773. }
  2774.  
  2775. void doMenu( long    whichMenuItem )
  2776.  
  2777. {
  2778. short    hi, lo;
  2779. Str255    itemString ;    /* the DA's official name */
  2780.  
  2781.     hi = ((whichMenuItem & 0xffff0000) >> 16) ;
  2782.     lo = (whichMenuItem & 0xffff) ;
  2783.     
  2784.     if ((hi == MENU_APPLE) && (lo == 1)) { /* About!! */
  2785.         /* check out these credits... */
  2786.         aboutPriv() ;
  2787.         HiliteMenu( 0 ) ;
  2788.         
  2789.     } /* end in about... */
  2790.     
  2791.     if ((hi == MENU_APPLE) && (lo >= 3)) { /* select a DA? */
  2792.         GetItem (gApplemenu, lo, itemString) ;
  2793.         OpenDeskAcc (itemString) ;
  2794.         HiliteMenu( 0 ) ;
  2795.     }
  2796.     
  2797.     if ((hi == kHMHelpMenuID ) && ( lo >= 3 )) {
  2798.     
  2799.         showInfoDialog( );
  2800.     
  2801.     }
  2802.         
  2803.     if ((hi == MENU_FILE && lo == 1)) { /* QUIT selected */
  2804.         shouldireallyquit( );
  2805.     }
  2806.     
  2807.     if (( hi == MENU_OPTION && lo == 1 )){ /* show or hide the negative acl box */
  2808.         if( gWindowstats.State == 0 ){ 
  2809.             createNegAclBox( );
  2810.         } else {
  2811.             deleteNegAclBox( );
  2812.         }
  2813.         HiliteMenu( 0 );
  2814.     }
  2815.     
  2816.     if ( hi == MENU_CONVIN ){
  2817.         instagroovyAcls( lo );
  2818.         HiliteMenu( 0 );    
  2819.     }
  2820.     
  2821. } /* end WhatToDoInMenu function */
  2822.  
  2823.  
  2824. void aboutPriv( ) 
  2825. {
  2826.     short        flag = kOff, itemHit = 0, okbuttontype;
  2827.     Rect        numberbox = { 0, 0, 0, 0 };
  2828.     Handle        number;
  2829.     Str255        whatImean = "\pElvis Lives!!!";
  2830.  
  2831.     if ( er.modifiers & optionKey ) { /* it is a cmd key function */
  2832.             flag = kOn;
  2833.     }
  2834.     
  2835.     if( flag == kOn ){ 
  2836.         if (( dr = GetNewDialog( DLOG_ELVS, NULL, (WindowPtr)-1 )) == NULL ) {
  2837.             goto failt;    
  2838.         }    
  2839.         GetDItem( dr, OKBUTTON, &okbuttontype, &number, &numberbox );
  2840.     } else {
  2841. failt:        if (( dr = GetNewDialog( DLOG_ABOUT, NULL, (WindowPtr)-1 )) == NULL ) {
  2842.             genericErrorstuff( 0, kOff, 23 );
  2843.         }
  2844.         GetDItem( dr, OKBUTTON, &okbuttontype, &number, &numberbox );
  2845.         if ( flag == kOn ) SetCTitle((ControlHandle)number, whatImean);
  2846.     }
  2847.     
  2848.  
  2849.     SetPort( dr );
  2850.     ShowWindow( dr );
  2851.  
  2852.     PenSize(3,3);
  2853.     InsetRect(&numberbox,-4,-4);
  2854.     FrameRoundRect(&numberbox,16,16); 
  2855.  
  2856.     ModalDialog( nil, &itemHit );
  2857.  
  2858.     DisposDialog( dr );
  2859.     SetPort( dp );
  2860. }
  2861.  
  2862. pascal void firstBox( theWindow, itemNo )
  2863.     WindowPtr     theWindow;
  2864.     short        itemNo;
  2865. {
  2866. #pragma unused ( itemNo );
  2867.     Rect        firstbox;
  2868.  
  2869.     firstbox = (*dirList)->rView;
  2870.     firstbox.top--;
  2871.     firstbox.bottom++;
  2872.     firstbox.right=firstbox.right+16; 
  2873.     firstbox.left--;
  2874.     FrameRect( &firstbox );
  2875.     if ( gWindowstats.Focus == 0 ) { /* focus is on this box */
  2876.         PenSize(2,2);
  2877.         InsetRect( &firstbox, -3, -3);
  2878.         ForeColor( blackColor );
  2879.         FrameRect( &firstbox );
  2880.         PenSize(1,1);
  2881.     }
  2882.     LUpdate( theWindow->visRgn, dirList );
  2883.     return;
  2884. }
  2885.  
  2886. pascal void secondBox( theWindow, itemNo )
  2887.     WindowPtr     theWindow;
  2888.     short        itemNo;
  2889. {
  2890. #pragma unused (theWindow, itemNo );
  2891.  
  2892.     Rect        myRect, thebox;
  2893.  
  2894.     LUpdate( theWindow->visRgn, gourList );    
  2895.     /* this part draws the rect that surrounds the list */
  2896.     thebox = (*gourList)->rView;
  2897.     thebox.top--;
  2898.     thebox.bottom++;
  2899.     thebox.right=thebox.right+16;
  2900.     thebox.left--;
  2901.     FrameRect( &thebox );
  2902.     myRect = thebox;
  2903.     ForeColor( whiteColor );
  2904.     PenSize( 2, 2);
  2905.     InsetRect( &myRect, -2, -2);
  2906.     FrameRect( &myRect ); 
  2907.     ForeColor( blackColor );
  2908.     PenSize( 1, 1 );
  2909.     if ( gWindowstats.Focus == 1 ) { /* focus is on THIS box... */
  2910.         PenSize(2,2);
  2911.         InsetRect( &thebox, -3, -3);
  2912.         ForeColor( blackColor );
  2913.         FrameRect( &thebox );
  2914.         PenSize(1,1);
  2915.     }
  2916.     return;
  2917. }
  2918.  
  2919. pascal void bonusBox( theWindow, itemNo )
  2920.     WindowPtr     theWindow;
  2921.     short        itemNo;
  2922. {
  2923. #pragma unused (theWindow, itemNo );
  2924.  
  2925.     Rect        myRect, thebox;
  2926.     FontInfo    fontStuff;
  2927.     short        fontNum;
  2928.  
  2929.     if ( gWindowstats.State == 1 ) {
  2930.         GetFNum((StringPtr)"\pChicago",&fontNum); // I do this in case the font has been mucked with
  2931.         TextFont(fontNum);
  2932.         TextFace(0);
  2933.         TextSize(12);
  2934.         GetFontInfo(&fontStuff);
  2935.         
  2936.         LUpdate( theWindow->visRgn, gnegAcls );
  2937.         /* this part draws the rect that surrounds the list */
  2938.         thebox = (*gnegAcls)->rView;
  2939.         thebox.top--;
  2940.         thebox.bottom++;
  2941.         thebox.right=thebox.right+16;
  2942.         thebox.left--;
  2943.         FrameRect( &thebox );
  2944.         myRect = thebox;
  2945.         ForeColor( whiteColor );
  2946.         PenSize( 2, 2);
  2947.         InsetRect( &myRect, -2, -2);
  2948.         FrameRect( &myRect ); 
  2949.         ForeColor( blackColor );
  2950.         PenSize( 1, 1 );
  2951.         if ( gWindowstats.Focus == 2 ) { /* focus is on THIS box... */
  2952.             PenSize(2,2);
  2953.             InsetRect( &thebox, -3, -3);
  2954.             ForeColor( blackColor );
  2955.             FrameRect( &thebox );
  2956.             PenSize(1,1);
  2957.         }
  2958.     }
  2959.     return;
  2960. }
  2961.  
  2962. pascal void growBox( theWindow, itemNo )
  2963.     WindowPtr     theWindow;
  2964.     short        itemNo;
  2965. {
  2966. #pragma unused (theWindow, itemNo );
  2967.     Rect        box;
  2968.     RgnHandle    rgn;
  2969.  
  2970.     SetPort( dp );    
  2971.     box = ((GrafPtr) dp)->portRect;
  2972.     box.left = box.right - 15;
  2973.     box.top = box.bottom - 15;
  2974.     rgn=NewRgn( );
  2975.     GetClip( rgn );
  2976.     ClipRect(&box);
  2977.     DrawGrowIcon( dp );
  2978.     SetClip( rgn );
  2979.     DisposeRgn( rgn );
  2980.  
  2981. pascal void popupBox( theWindow, itemNo )
  2982.     WindowPtr     theWindow;
  2983.     short        itemNo;
  2984. {
  2985. #pragma unused (theWindow, itemNo );
  2986.  
  2987.     Cell        place;
  2988.     short        dataLen, fontNum;
  2989.     int            textpixelsize, charpixelsize;
  2990.     char        volumeName[255];
  2991.     Rect        box, wholebox = RECT_POPUPMENU;
  2992.     FontInfo    allaboutChicago;
  2993.     SICNHand    sicnhandle;
  2994.     Str255        namedisplayed;
  2995.     short        textswidth;
  2996.     
  2997.     SetPort( dp );    
  2998.     dataLen = 255; /* the length will be corrected to the real thing when we get the cell */
  2999.     place.h = 0;
  3000.     place.v = gTopLevel; /* this is set to whatever level we are at... 0 for top */
  3001.     LGetCell( namedisplayed+1, &dataLen, place, gpathList );
  3002.     namedisplayed[0] = dataLen;
  3003.     GetFNum((StringPtr)"\pChicago",&fontNum); /* set our font */
  3004.     TextFont(fontNum);
  3005.     TextFace(0);
  3006.     TextSize(12);
  3007.     GetFontInfo( &allaboutChicago );
  3008.     textpixelsize = StringWidth( volumeName );
  3009.     charpixelsize = CharWidth( ' ' );
  3010.     CalcMenuSize( gPopupMenu );
  3011.     box.top = wholebox.top;
  3012.     box.left = wholebox.left;
  3013.     box.bottom = 2+1+allaboutChicago.ascent+allaboutChicago.descent+allaboutChicago.leading;
  3014.     TruncString(( wholebox.right - wholebox.left - ( SIZEOFSICN * 2 )), &namedisplayed, smTruncEnd );
  3015.     textswidth = ( StringWidth( namedisplayed ) + ( SIZEOFSICN * 2))-7;
  3016.     box.right = ( box.left + textswidth );
  3017.     EraseRect( &wholebox );
  3018.     InsetRect( &box, -1, -1 );
  3019.     box.top++;
  3020.     box.bottom = wholebox.top+20;
  3021.     wholebox = box;
  3022.     
  3023.     // I don't know why these SICNS behave this way... I just kludged it...
  3024.     if( gTopLevel == 0 ) wholebox.top = wholebox.top+3;
  3025.     else wholebox.top = wholebox.top+2;
  3026.     
  3027.     wholebox.left = wholebox.left+15;
  3028.     wholebox.right = wholebox.left + 16;
  3029.     wholebox.bottom = wholebox.top + 16;
  3030.     if( gTopLevel == 0 ) sicnhandle = (SICNHand)GetResource( 'SICN', SICN_DESK );
  3031.     if( gTopLevel == 1 ) sicnhandle = (SICNHand)GetResource( 'SICN', SICN_SHAR );
  3032.     if( gTopLevel > 1 ) sicnhandle = (SICNHand)GetResource( 'SICN', SICN_OPEN );
  3033.     HLock((Handle) sicnhandle );
  3034.     PlotSICN( &wholebox, sicnhandle, 0 );
  3035.     HUnlock((Handle) sicnhandle );
  3036.     FrameRect( &box );
  3037.     MoveTo( box.left+3 , box.bottom); /* moves to the bottom of the Rectangle */
  3038.     PenSize( 1, 1);
  3039.     LineTo((box.left+textswidth+2), box.bottom);
  3040.     LineTo((box.left+textswidth+2), box.top+2);
  3041.     MoveTo( box.left+35,( box.bottom-allaboutChicago.descent-allaboutChicago.leading-2) );
  3042.     DrawString( &namedisplayed );
  3043.     wholebox.left = ( box.left + 4 + StringWidth( namedisplayed ) + SIZEOFSICN );
  3044.     wholebox.top = box.top+2;
  3045.     wholebox.bottom = wholebox.top+16;
  3046.     wholebox.right = wholebox.left + 16;
  3047.     sicnhandle = (SICNHand)GetResource( 'SICN', SICN_DOWN );
  3048.     HLock((Handle) sicnhandle );
  3049.     PlotSICN( &wholebox, sicnhandle, 0 );
  3050.     HUnlock((Handle) sicnhandle );
  3051. }
  3052.  
  3053. pascal void posornegBox( theWindow, itemNo )
  3054.     WindowPtr     theWindow;
  3055.     short        itemNo;
  3056. {
  3057. #pragma unused (theWindow, itemNo );
  3058.  
  3059.     short        fontNum, boxthebutton;
  3060.     int        textpixelsize, charpixelsize;
  3061.     FontInfo    allaboutChicago;
  3062.     Handle        nothingspecial;
  3063.     Rect        box;
  3064.     
  3065.     SetPort( dp );    
  3066.     GetDItem( dp, ITEM_POSITIVE, &boxthebutton, ¬hingspecial, &box );
  3067.     GetFNum((StringPtr)"\pChicago",&fontNum); /* set our font */
  3068.     TextFont(fontNum);
  3069.     TextFace(0);
  3070.     TextSize(12);
  3071.     GetFontInfo( &allaboutChicago );
  3072.     textpixelsize = StringWidth( "\pPositive Access" );
  3073.     charpixelsize = CharWidth( ' ' );
  3074.     box.bottom = box.top + 18;
  3075.     box.right = box.left + 132;
  3076.     
  3077.     EraseRect( &box );
  3078.  
  3079.     MoveTo( box.left+1 , box.top+9); /* moves to the bottom of the Rectangle */
  3080.     PenPat( &qd.gray );
  3081.     PenSize( 1, 1);
  3082.     LineTo( box.left+14, box.top+9 );
  3083.     MoveTo( box.right-9, box.top+9 );
  3084.     LineTo( box.right+2, box.top+9);
  3085.     PenPat( &qd.black );
  3086.     MoveTo( box.left+16 , (box.bottom-allaboutChicago.descent-allaboutChicago.leading-1));
  3087.     DrawString( "\pPositive Access" );
  3088.  
  3089. }
  3090.  
  3091. pascal void negativeBox( theWindow, itemNo )
  3092.     WindowPtr     theWindow;
  3093.     short        itemNo;
  3094. {
  3095. #pragma unused (theWindow, itemNo );
  3096.  
  3097.     short        fontNum, boxthebutton;
  3098.     int        textpixelsize, charpixelsize;
  3099.     FontInfo    allaboutChicago;
  3100.     Handle        nothingspecial;
  3101.     Rect        box;
  3102.     
  3103.     if ( gWindowstats.State == 1 ) {
  3104.         SetPort( dp );    
  3105.         GetDItem( dp, ITEM_NEGTITLE, &boxthebutton, ¬hingspecial, &box );
  3106.         GetFNum((StringPtr)"\pChicago",&fontNum); /* set our font */
  3107.         TextFont(fontNum);
  3108.         TextFace(0);
  3109.         TextSize(12);
  3110.         GetFontInfo( &allaboutChicago );
  3111.         textpixelsize = StringWidth( "\pNegative Access" );
  3112.         charpixelsize = CharWidth( ' ' );
  3113.         GetDItem( dp, ITEM_SECONDBOX, &boxthebutton, ¬hingspecial, &box );
  3114.         box.top = box.bottom + 5;
  3115.         box.bottom = box.top + 18;
  3116.         box.right = box.left + 132;
  3117.         
  3118.         EraseRect( &box );
  3119.  
  3120.         MoveTo( box.left+1 , box.top+9); /* moves to the bottom of the Rectangle */
  3121.         PenPat( &qd.gray );
  3122.         PenSize( 1, 1);
  3123.         LineTo( box.left+15, box.top+9 );
  3124.         MoveTo( box.right-9, box.top+9 );
  3125.         LineTo( box.right+2, box.top+9);
  3126.         PenPat( &qd.black );
  3127.         MoveTo( box.left+16 , (box.bottom-allaboutChicago.descent-allaboutChicago.leading-1));
  3128.         DrawString( "\pNegative Access" );
  3129.     }
  3130. }
  3131.  
  3132. OSErr    GetIndVolume(short whichVol, char *volName, short *volRefNum)
  3133. {
  3134.     /* return the name and vRefNum of volume specified by whichVol. */
  3135.  
  3136.     HVolumeParam    volPB;
  3137.     OSErr        error;
  3138.     
  3139.     volPB.ioNamePtr = volName; /* make sure it returns the name */
  3140.     volPB.ioVRefNum = 0;       /* 0 means use ioVolIndex */
  3141.     volPB.ioVolIndex = whichVol; /* use this to determine the volume */
  3142.     
  3143.     error = PBHGetVInfo( (HParmBlkPtr)&volPB,false ); /* do it */
  3144.     if (error == noErr) /* if no error occurred */
  3145.         *volRefNum = volPB.ioVRefNum; /* return the volume reference */
  3146.         
  3147.     /* other information is available from this record; see the FILE */
  3148.     /* Manager's description of PBHGetVInfo for more details... */
  3149.     
  3150.     return(error); /* always return error code */
  3151. } /* GetIndVolume */
  3152.  
  3153. void bzero( char *p, long len )        /* cleans out a pointer so that we pass */
  3154.                                        /* only the information we want to      */
  3155.     char    *p;                     /* PBHDelete                            */
  3156.     long    len;
  3157. {
  3158.     for ( ; len > 0; --len ) {
  3159.         *p++ = 0;
  3160.     }
  3161. }
  3162.  
  3163. void makeList( )
  3164. {
  3165.     /* create the list of mounted volumes.... */
  3166.  
  3167.     short         whichVol, volRefNum = 0, length, numberoflistentries = 0;
  3168.     short        countAfs = 1, k, howmany;
  3169.     char        volName[255], up;
  3170.     OSErr        whaterror;
  3171.     Rect        box = { 32, 9, 32+130, 9+163-15 }, bounds;
  3172.     Point        place;
  3173.     Cell        whatbox;
  3174.     HParamBlockRec    audioCheck;
  3175.     
  3176.     Show_Cursor((Cursors) ACUR_SPIN); 
  3177.     LDoDraw( false, gourList );
  3178.     LDoDraw( false, dirList );
  3179.     for(k=0;k<255;k++) {
  3180.         volName[k] = 0;
  3181.     }
  3182.     
  3183.     bounds = box;
  3184.     place.h = box.left;
  3185.     place.v = box.top;
  3186.     howmany = 0;
  3187.     
  3188.     for (whichVol=1;;whichVol++) {
  3189.         if (GetIndVolume( whichVol, volName, &volRefNum) == nsvErr) break;
  3190.         vcb = (AVCB *)(getVCBbyrefnum( volRefNum ));
  3191.         SpinCursor( 8 );
  3192.         if (isafsVCB( vcb ) == true) {
  3193.             bzero(( char *)&audioCheck, sizeof( HParamBlockRec ));
  3194.             audioCheck.fileParam.ioCompletion = nil;
  3195.             audioCheck.fileParam.ioNamePtr = volName;
  3196.             audioCheck.fileParam.ioVRefNum = volRefNum;
  3197.             if( whaterror = PBHGetVInfo( &audioCheck, false ) != noErr ){
  3198.                 genericErrorstuff((long)whaterror, kOn, 19 );
  3199.             }
  3200.             if (!( audioCheck.volumeParam.ioVFSID & 0x4A48 )){
  3201.                 length = volName[0];
  3202.                 if (getdirAcl( volRefNum, OBNOXIOUSHIGHNUMBER ) == true) {
  3203.                     up = -volRefNum;
  3204.                     CompareandInsert( volName, up, numberoflistentries++ );
  3205.                     howmany++;
  3206.                 }
  3207.             }
  3208.         }
  3209.     }
  3210.      if ( howmany == 0 ) {
  3211.         Show_Cursor( ARROW_CURSOR ); 
  3212.         noAFSmounted( );
  3213.         return;
  3214.     }
  3215.     
  3216.     whatbox.h = 0;         /* we should always be in here as we just */
  3217.     whatbox.v = 0;         /* rebuilt the damned directory list... */
  3218.     if ( !LGetSelect( true, &whatbox, dirList )) {
  3219.         LSetSelect( true, whatbox, dirList );
  3220.     }
  3221.     LDelRow( 0, 2000, gourList ); /* deletes everything in the acl list */
  3222.     LDelRow( 0, 2000, gnegAcls );
  3223.     whatbox.h = 1;
  3224.     length=1;
  3225.     LGetCell( &up, &length, whatbox, dirList );
  3226.     if( getdirAcl( -up, 0 ) == false ){
  3227.         /* this should never be false since it's already in our list
  3228.          * as an AFS volume                                          */
  3229.         genericErrorstuff(-66669, kOn, 55 );
  3230.     }
  3231.     
  3232.     buildACL( );
  3233.  
  3234.     LDoDraw( true, dirList );
  3235.     LUpdate( dp->visRgn, dirList );
  3236.     LDoDraw( true, gourList );
  3237.     LUpdate( dp->visRgn, gourList );
  3238.     if ( gWindowstats.State == 1 ) {
  3239.         LDoDraw( true, gnegAcls );
  3240.         LUpdate( dp->visRgn, gnegAcls );
  3241.     }
  3242.     gLocation = 0;
  3243.     showRights( 0 );
  3244.     Show_Cursor( ARROW_CURSOR ); 
  3245.     return;
  3246. }
  3247.  
  3248. short CompareandInsert( char listentry[255], char up, short entriesinlist ){
  3249.  
  3250.     Boolean    endflag;
  3251.     Cell    wherearewe = { 0, 0 };
  3252.     short    dataLen, length;
  3253.     int     j;
  3254.     short    cameback;
  3255.     
  3256.     Str255    checking, comparedto;
  3257.     
  3258.     strncpy( checking+1, listentry+1, listentry[0] );
  3259.     checking[0] = listentry[0];
  3260.     UprString( &checking, false );
  3261.  
  3262.     if( entriesinlist == 0 ) endflag = false;
  3263.     else endflag = true;
  3264.     
  3265.     wherearewe.v = 0;
  3266.     do {
  3267.         dataLen = 512;
  3268.         wherearewe.h = 0;
  3269.         if( endflag != false ) {
  3270.             LGetCell( comparedto+1, &dataLen, wherearewe, dirList );
  3271.             comparedto[0] = dataLen;
  3272.             comparedto[dataLen+1] = 0;
  3273.             UprString( &comparedto, false );
  3274.             if( cameback = ( IUCompString( checking, comparedto )) < 0 ) endflag = false;
  3275.             else endflag = LNextCell( false, true, &wherearewe, dirList );
  3276.         }
  3277.     } while ( endflag == true );
  3278.     
  3279.     listentry[listentry[0]+1] = 0;
  3280.     length = strlen( listentry + 1 );
  3281.     if( length <= 0 ) return 0;
  3282.     wherearewe.v = LAddRow( 1, wherearewe.v, dirList );
  3283.     LSetCell( listentry+1, length, wherearewe, dirList);
  3284.     wherearewe.h = 1;
  3285.     j = 1;
  3286.     LSetCell( &up, j, wherearewe, dirList );
  3287.     return 0;
  3288. }
  3289.  
  3290. void makedirList( Str255 path, long vRefNum )
  3291. {
  3292.  
  3293. CInfoPBRec    paramBlock;
  3294. long        whatthehell, tempfolderid, directoryid, volumeid;
  3295. WDPBRec        wdBlock;
  3296. OSErr        reportCode;
  3297. char        neato[255], listentry[255], up;
  3298. Cell        whatbox;
  3299. short        count=0, countDir = 0, howmany, length, alpha, numberoflistentries = 0;
  3300.  
  3301.     // I'm spinning the cursor because I'm assuming we have a spinning watch at this point
  3302.     Show_Cursor((Cursors) ACUR_SPIN); 
  3303.     bzero((char *)¶mBlock, sizeof( CInfoPBRec ));
  3304.     volumeid = vRefNum;
  3305.     wdBlock.ioVRefNum = vRefNum;
  3306.     wdBlock.ioWDIndex = 0;
  3307.     wdBlock.ioWDProcID = 0;
  3308.     SpinCursor( 8 );
  3309.     LDelRow( 0, 2000, dirList ); /* deletes everything in the list */
  3310.     LDoDraw( false, dirList );
  3311.     paramBlock.hFileInfo.ioNamePtr = path;
  3312.     paramBlock.hFileInfo.ioVRefNum = vRefNum;
  3313.     paramBlock.hFileInfo.ioCompletion = 0;
  3314.     paramBlock.hFileInfo.ioFDirIndex = 0;
  3315.     paramBlock.hFileInfo.ioDirID = 0;
  3316.     if ( whatthehell = (PBGetCatInfo( ¶mBlock, false ) != noErr )) {
  3317.         genericErrorstuff( whatthehell, kOff, 20 );
  3318.     }
  3319.     if ( paramBlock.hFileInfo.ioResult != noErr ) genericErrorstuff((long) paramBlock.hFileInfo.ioResult, kOff, 21 );
  3320.     tempfolderid = paramBlock.hFileInfo.ioDirID;
  3321.     howmany = 0;
  3322.     do {
  3323.         SpinCursor( 12 );
  3324.         for (alpha=0;alpha<255;alpha++) {
  3325.             listentry[alpha] = neato[alpha] = 0;
  3326.         }
  3327.         
  3328.         if ( buildLoop( ) == 1 ){
  3329.             SysBeep( 0 );
  3330.             break;
  3331.         }
  3332.         paramBlock.hFileInfo.ioFDirIndex = ++count; 
  3333.         paramBlock.hFileInfo.ioDirID = tempfolderid;
  3334.         paramBlock.hFileInfo.ioVRefNum = vRefNum;
  3335.         paramBlock.hFileInfo.ioNamePtr = neato;
  3336.         paramBlock.hFileInfo.ioFVersNum = 0;
  3337.         paramBlock.hFileInfo.ioCompletion = 0L;        
  3338.         reportCode = PBGetCatInfo( ¶mBlock, false );
  3339.         if( reportCode = paramBlock.hFileInfo.ioResult != noErr ); /* I don't discard this error,
  3340.                                           we merely hold it until the
  3341.                                           end of the while loop and if
  3342.                                           there IS an error, get out!*/
  3343.                                           
  3344.         if( BitTst(¶mBlock.hFileInfo.ioFlAttrib,3) == true ) { /* tests to see if the "file" is */
  3345.         /* a directory, which is the only thing you can set acls on in afs-land... */
  3346.             length = strlen( neato );
  3347.             neato[length+1]=0;
  3348.             for(alpha=0;alpha<=length;alpha++) {
  3349.                 listentry[alpha+1] = neato[alpha];
  3350.             }
  3351.             SpinCursor( 12 );
  3352.             listentry[0] = length;
  3353.             neato[0] = length;
  3354.             whatbox.h = 0;
  3355.             if ( countDir == 0 ) directoryid = paramBlock.hFileInfo.ioDirID;
  3356.             whatbox.v = countDir++ - 1;
  3357.             if ( length > 1 ) {
  3358.                 up = paramBlock.hFileInfo.ioDirID;
  3359.                 listentry[1]=listentry[0];
  3360.                 CompareandInsert( listentry+1, up, numberoflistentries++ );
  3361.                 howmany++;
  3362.             }  /* end if-length check */
  3363.         }    
  3364.     } while ( reportCode == noErr );
  3365.     LDoDraw( true, dirList );
  3366.     LUpdate( dp->visRgn, dirList );
  3367.     
  3368.     whatbox.h = 0;         /* we should always be in here as we just */
  3369.     whatbox.v = 0;         /* rebuilt the damned directory list... */
  3370.     if ( !LGetSelect( true, &whatbox, dirList )) {
  3371.         LSetSelect( true, whatbox, dirList );
  3372.     }
  3373.     LDelRow( 0, 2000, gourList ); /* deletes everything in the acl list */
  3374.     LDelRow( 0, 2000, gnegAcls );
  3375.     
  3376.     if( howmany > 0 ){
  3377.         whatbox.h = 1;
  3378.         length=1;
  3379.         LGetCell( &up, &length, whatbox, dirList );
  3380.         if( getdirAcl( volumeid, up ) == false ){
  3381.             /* this should never be false since it's already in our list
  3382.              * as an AFS volume                                          */
  3383.             genericErrorstuff(-66669, kOn, 58 );
  3384.         }
  3385.     }
  3386.     LDoDraw( true, gourList );
  3387.     LUpdate( dp->visRgn, gourList );
  3388.     if ( gWindowstats.State == 1 ) {
  3389.         LDoDraw( true, gnegAcls );
  3390.         LUpdate( dp->visRgn, gnegAcls );
  3391.     }
  3392.     gLocation = 0;
  3393.     showRights( 0 );
  3394.     Show_Cursor( ARROW_CURSOR ); 
  3395.     return;
  3396. }
  3397.  
  3398. void shouldireallyquit( void ){
  3399.  
  3400.     Handle    number;
  3401.     Rect    numberbox;
  3402.     short    okbuttontype, itemHit;
  3403.     
  3404.     if ( gAChange <= 0) termiNate( );
  3405.     
  3406.     if (( dr = GetNewDialog( DLOG_QUIT, NULL, (WindowPtr)-1 )) == NULL ) {
  3407.         ExitToShell();
  3408.     }
  3409.  
  3410.     SetPort( dr );
  3411.     ShowWindow( dr );
  3412.     
  3413.     GetDItem( dr, 1, &okbuttontype, &number, &numberbox );
  3414.     
  3415.     PenSize(3,3);
  3416.     InsetRect(&numberbox,-4,-4);
  3417.     FrameRoundRect(&numberbox,16,16);
  3418.     SysBeep( 0 );    
  3419.     ModalDialog( nil, &itemHit );
  3420.     switch( itemHit ) {
  3421.     case 1 : /* hit the Save button */
  3422.             DisposDialog( dr );
  3423.             buildACL( );
  3424.             termiNate( );
  3425.             break;
  3426.     case 2 : /* hit the Don't Save button */
  3427.             DisposDialog( dr );
  3428.             termiNate( );
  3429.             break;
  3430.     case 3 : /* hit the cancel button */
  3431.             DisposDialog( dr );
  3432.             SetPort( dp );
  3433.             return;
  3434.             break;
  3435.     }
  3436.  
  3437.  
  3438. }
  3439.  
  3440. Boolean getdirAcl( short volRefNum, long directid ) 
  3441. {
  3442.     Str255            foldName;
  3443.     XPPParamBlock    xpp;
  3444.     CInfoPBRec        cInfoRec;
  3445.     char            buffer[1000], cmd[9];
  3446.     OSErr            err;
  3447.     long            *did, afpreturns, MyCurDir;
  3448.     short            xppRNum, *vid;
  3449.     Boolean            done;
  3450.  
  3451.     
  3452.     /* directid is OBNOXIOUSHIGHNUMBER only if I want to know if this is an AFS directory */
  3453.     
  3454.     if ( directid == OBNOXIOUSHIGHNUMBER ) MyCurDir = 2L;
  3455.     else {
  3456.     
  3457.         // cursor should be a spinning watch at this point....
  3458.         LDoDraw( false, gnegAcls );
  3459.         LDoDraw( false, gourList );
  3460.         SpinCursor( 8 );
  3461.         if ( gTopLevel == 0 ) {
  3462.             MyCurDir = 2L; /* root directory of a vol is 2 */
  3463.         } else { 
  3464.             MyCurDir = directid;
  3465.         }
  3466.     }
  3467.  
  3468.     // here's my attempt to get the vcb
  3469.     vcb = (AVCB*)0x0358;
  3470.     done = false;
  3471.     while ((vcb != 0L) && !done)
  3472.     {
  3473.         if (vcb->vcbVRefNum == volRefNum)
  3474.         {
  3475.             if (vcb->vcbFSID != 0)
  3476.                 done = true;
  3477.             else    
  3478.                 vcb = (AVCB*)vcb->qLink;
  3479.         }
  3480.         else
  3481.             vcb = (AVCB*)vcb->qLink;
  3482.     }
  3483.  
  3484.     SpinCursor( 8 );
  3485.     cInfoRec.dirInfo.ioNamePtr = (StringPtr) &foldName;
  3486.     cInfoRec.dirInfo.ioVRefNum = volRefNum;
  3487.     cInfoRec.dirInfo.ioFDirIndex = -1;
  3488.     cInfoRec.dirInfo.ioDrDirID = MyCurDir;
  3489.     PBGetCatInfo(&cInfoRec,false);
  3490.     
  3491.     bzero( buffer, 1000L);
  3492.     bzero( (char *)&xpp, sizeof(XPPParamBlock));
  3493.     SpinCursor( 6 );
  3494.     if ( OpenXPP( &xppRNum ) != noErr ) {
  3495.         DebugStr("\p hey dude");
  3496.     }
  3497.     
  3498.     /* Set Up request. */
  3499.     cmd[0] = 100; /* the first cmd byte says "get acl" */
  3500.     cmd[1] = 0;
  3501.     vid = (short*)&cmd[2];
  3502.     did = (long*)&cmd[4];
  3503.  
  3504.     *did = MyCurDir;
  3505.     *vid = (short)vcb->vcbServerVol;
  3506.     cmd[8] = 2;
  3507.     cmd[9] = 0;
  3508.     
  3509.     xpp.XPP.sessRefnum = vcb->vcbSRefNum;
  3510.     xpp.XPP.ioRefNum = xppRNum;
  3511.     xpp.XPP.ioCompletion = 0L;
  3512.     xpp.XPP.csCode = 250;
  3513.     xpp.XPP.aspTimeout = 2;
  3514.     xpp.XPP.cbSize = 10;
  3515.     xpp.XPP.cbPtr = cmd;
  3516.     xpp.LOGIN.rbSize = 1000;
  3517.     xpp.LOGIN.rbPtr = buffer;
  3518.  
  3519.     err = AFPCommand(&xpp, false); /* do a test for noErr!!!!!!!!!!! */
  3520.     afpreturns = xpp.XPP.cmdResult;
  3521.     SpinCursor( 6 );
  3522.     
  3523.     if( directid == OBNOXIOUSHIGHNUMBER ){
  3524.         if( afpreturns == noErr ) return true;
  3525.         else return false;
  3526.     }
  3527.     
  3528.     if (afpreturns == noErr)
  3529.     {
  3530.         if (( gInitialize == kOff ) && ( ++gManyAcls == 1 )) {
  3531.             parseStr( buffer );
  3532.         }
  3533.         if ( gInitialize == kOn ) {
  3534.             parseStr( buffer );
  3535.         }
  3536.         return true;    
  3537.     }
  3538.     /* else
  3539.         tell the user something went wrong */
  3540. /* DebugStr("\pafp has an error..."); I get this when a volume is down */
  3541. //    SysBeep( 0 ); nyahh.. we'll deal with it later...
  3542.     return false;
  3543. }
  3544.  
  3545. void instagroovyAcls( short whatoption ){
  3546.  
  3547. /* comes from doMenu with the user selecting a certain cool access privilege s/he'd like
  3548.    to put on an acl name that they have permission to do.... */
  3549.    
  3550. Cell    where,    // what directory/volume name? 
  3551.         cSize = {0, 0};    // what group/user name?
  3552. short    objSize, focus, whatrow, permSize,
  3553.         value;     // the sum of which equals the access
  3554. int        i, j;
  3555. char    k, right, objectName[256];
  3556.  
  3557.     where.h = 0;
  3558.     where.v = 0;
  3559.     if ( !LGetSelect( true, &where, dirList )) {
  3560.         LSetSelect( true, where, dirList );
  3561.     }
  3562.     whatrow = where.v;
  3563.     
  3564.     if ( whatoption == 1 ) value =   9;    // = read + lookup
  3565.     if ( whatoption == 2 ) value =  12;     // = insert + lookup
  3566.     if ( whatoption == 3 ) value =  63;     // = everything except permit
  3567.     if ( whatoption == 4 ) value = 127;    // = everything
  3568.  
  3569.     if ( gWindowstats.Focus == 1 ) focus = 1;
  3570.     if ( gWindowstats.Focus == 2 ) focus = 2;
  3571.     if ( gWindowstats.Focus == 0 ) {
  3572.         if ( LGetSelect( true, &cSize, gourList ) == false ) {
  3573.             if ( LGetSelect( true, &cSize, gnegAcls ) == false ) return;
  3574.             focus = 2;
  3575.         } else focus = 1;
  3576.         cSize.h = 0;
  3577.         cSize.v = 0;
  3578.     }
  3579.     
  3580.     objSize = 255;
  3581.     
  3582.     if( focus == 2 ) LGetSelect( true, &cSize, gnegAcls );
  3583.     else LGetSelect( true, &cSize, gourList );
  3584.     cSize.h = 0;
  3585.     
  3586.     if ( focus == 2 ) LGetCell(&objectName, &objSize, cSize, gnegAcls );
  3587.     else LGetCell(&objectName, &objSize, cSize, gourList);
  3588.     
  3589.     if (objSize != 0)
  3590.     {
  3591.         /* Get the permission string. */
  3592.         cSize.h = 1;
  3593.         permSize = 1;
  3594.         
  3595.         if ( focus == 2 ) LGetCell(&right, &permSize, cSize, gnegAcls);
  3596.         else LGetCell(&right, &permSize, cSize, gourList);
  3597.         i = right;
  3598.         if ( i < 0) { /* negative??  */
  3599.             sneakyNegative ( i );
  3600.         }
  3601.  
  3602.         /* and then reset it */
  3603.         j = 1;
  3604.         k = value;  // just replace whatever is in there now with our new value
  3605.         if ( focus == 2 ) LSetCell(&k, j, cSize, gnegAcls );
  3606.         else LSetCell(&k, j, cSize, gourList);
  3607.         gAChange = whatrow+1; 
  3608.     } else genericErrorstuff( -66670, kOn, 20 ); /* we should never be in here... */
  3609.     showRights( cSize.v );
  3610. }